FriendsOfPHP / Goutte

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

Peer certificate cannot be authenticated with given CA certificates for https://example.com #437

Closed Leleking closed 3 years ago

Leleking commented 3 years ago

I am using this package with laravel. Locally, it works just fine but after deploying to the server I get this error Symfony\Component\HttpClient\Exception\TransportException: Peer certificate cannot be authenticated with given CA certificates for https://example.com

Leleking commented 3 years ago

After digging around i found the fix. use Symfony\Component\HttpClient\HttpClient;

$url = 'https://www.bog.gov.gh/treasury-and-the-markets/daily-interbank-fx-rates/'; $client = new Client(HttpClient::create(['verify_peer' => false, 'verify_host'=> false])); $crawler = $client->request('GET', $url);

stof commented 3 years ago

note that disabling peer verification is insecure though. You should rather make sure that CA certificates are configured properly on your server.