5

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 Goutte\Client;

$client = new Client();

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

How to fix this?

2 Answers 2

13

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

use Goutte\Client;
use Symfony\Component\HttpClient\HttpClient;

$client = new Client(HttpClient::create(['verify_peer' => false, 'verify_host' => false]));
$client->request('GET', 'https://example.com');
2
  • But there's no setClient method in Goutte\Client
    – Mesolaries
    Aug 22, 2020 at 17:59
  • 1
    Changed to HttpClient for newer versions of Symfony.
    – 3y3skill3r
    Aug 22, 2020 at 18:12
1

If you work in localhost, you can disable SSL check globaly into config/packages/frameworks.yaml and paste this :

http_client:
    default_options:
        verify_host: false
        verify_peer: false

Hope that's help you !

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.