Skip to content
Advertisement

How can I fix the SSL problem in Symfony/Goutte

I’m trying to make a request to the website with Symfony/Goutte but I’m receiving such error:

In ErrorChunk.php line 65:
                                                                                                         
  SSL peer certificate or SSH remote key was not OK for "https://example.com".  
                                                                                                         
In CurlResponse.php line 298:
                                                                                                         
  SSL peer certificate or SSH remote key was not OK for "https://example.com".

Here’s the code:

use GoutteClient;

$client = new Client();

$client->request('GET', 'https://example.com');

How to fix this?

Advertisement

Answer

You need to add HttpClient and disable SSL check… (do this only for debug) not in production!

use GoutteClient;
use SymfonyComponentHttpClientHttpClient;

$client = new Client(HttpClient::create(['verify_peer' => false, 'verify_host' => false]));
$client->request('GET', 'https://example.com');
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement