91

This should be an easy thing to do. I can find plenty of references to how to do it in Guzzle 3, but they don't work in Guzzle 5.

What I am doing so far:

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

When I send a request though I get this error:

RequestException in RequestException.php line 51:
SSL CA bundle not found: false

I cannot find any useful reference to this error on google. If I could get access to the curl options then I could try something like the solution suggested here (which is for Guzzle 3, hence why it doesn't work): http://inchoo.net/dev-talk/symfony2-guzzle-ssl-self-signed-certificate/, the relevant section of which is:

$req->getCurlOptions()->set(CURLOPT_SSL_VERIFYHOST, false);
$req->getCurlOptions()->set(CURLOPT_SSL_VERIFYPEER, false);
Gnuffo1
  • 3,478
  • 11
  • 39
  • 53
  • OK, apparently I'm just bad at reading the docs. Eventually found this: http://docs.guzzlephp.org/en/latest/faq.html?highlight=ssl#how-can-i-add-custom-curl-options – Gnuffo1 Jan 21 '15 at 11:48

4 Answers4

103

You should use

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

i.e. a Boolean false, not the string 'false'

The documentation is here: https://docs.guzzlephp.org/en/5.3/clients.html#verify

Note: a few people have given other answers that apply to Guzzle 6+. They're good answers if you are using those versions (but the original question was explicitly about Guzzle 5).

pjcdawkins
  • 1,256
  • 1
  • 7
  • 8
  • 50
    The ```defaults``` is actually not a part of the Guzzle 5 Client's config. You should use: $this->client = new GuzzleClient([ 'verify' => false ]); – tixastronauta Jan 12 '16 at 18:05
  • 6
    Docs page is slightly changed to: http://guzzle.readthedocs.io/en/latest/request-options.html#verify – bootoffav May 25 '16 at 08:44
  • 1
    To clarify, this answer is specific to Guzzle 5 (the version mentioned in the question), which does have `defaults` (see http://docs.guzzlephp.org/en/5.3/clients.html). – pjcdawkins Aug 02 '19 at 14:34
63

Try with updated version that works:

$this->client = new GuzzleClient(['base_uri' => 'https://api.example.com/', 'verify' => false ]);

or a more simple version:

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

Tested with version 6.2-dev.

SND
  • 639
  • 5
  • 3
58

The actual version is the correct one:

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

At 2018, this does not work:

$this->client = new GuzzleClient(['defaults' => [
    'verify' => false
]]);
PriNcee
  • 2,436
  • 3
  • 17
  • 21
12

you can use in the new laravel client version with

$http = new Client(['verify' => false]);
Alaa Moneam
  • 509
  • 5
  • 10