Search code examples
phpsslcurlgoutte

Setting CURL Parameters for fabpot/goutte Client


I am working on a web crowler using goutte (fabpot/goutte). When I try to connect to an https site, it throws an error because the site is using a self signed certificate. I am trying to find the way to set the curl parameters to ignore the fact that the ssl certificate is self signed. Following the instructions in https://github.com/FriendsOfPHP/Goutte I tried the following code:

    $this->client = new Client();
    $this->client->getClient()->setDefaultOption('config/curl/'.CURLOPT_SSL_VERIFYPEER, false);
    $this->client->getClient()->setDefaultOption('config/curl/'.CURLOPT_CERTINFO, false);

Unfortunately when this code is executed the following error is thrown:

Catchable fatal error: Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, boolean given

Can't figure out how to set up the parameters. How is the call expected? Any help will be appreciated.


Solution

  • What I ended up doing is the following:

    $this->client->setClient(new GuzzleClient(['verify' => false]));
    

    The 'verify' => false when initiating the GuzzleClient makes it not verify the certificates.