FriendsOfPHP / Goutte

Goutte, a simple PHP Web Scraper
MIT License
9.25k stars 1.01k forks source link

cURL error 60: SSL certificate problem: unable to get local issuer certificate #214

Open rashedshaon opened 9 years ago

rashedshaon commented 9 years ago

I want crawl a site which is HTTPS: The following error occurred when I start crawling. RequestException in RequestException.php line 51: cURL error 60: SSL certificate problem: unable to get local issuer certificate

larowlan commented 9 years ago

From your machine can you test if you can fetch it via curl on the cli? Suspect its your SSL configuration.

gnovaro commented 8 years ago

after that updates the library @stable with composer I have the same problem

curl https://www.xxxxx.com/category/market/ curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.

ssanders commented 8 years ago

Set Goutte 2’s CURLOPT_SSL_VERIFYPEER to false, or search issues for other Goutte versions.

$client->getClient()->setDefaultOption('config/curl/' . CURLOPT_SSL_VERIFYPEER, false);
gnovaro commented 8 years ago

Thanks for your answer, now works but I use this format //Scrapper use Goutte\Client;

$client = new \Goutte\Client();

// Create and use a guzzle client instance that will time out after 90 seconds $guzzleClient = new \GuzzleHttp\Client(array( 'timeout' => 90, 'verify' => false, ));

$client->setClient($guzzleClient);

TSerra-PT commented 7 years ago

Thank you so much @gnovaro :D Your solution works well here!

stof commented 7 years ago

Note that disabling the peer verification is not a solution. It is a security issue as it means you are not checking the SSL certificate anymore, defeating the purpose of HTTPS. Instead, you should fix your system so that it has the proper CA file to be able to validate certificates.

TSerra-PT commented 7 years ago

so what is the best solution? @stof