In previous post I explained to install and setup Guzzle Php web client library with help of GuzzleBundle for Symfony2.
Now I am going to explain how to use it with SSL self-signed certificate.
It’s pretty easy to implement, since Guzzle web client library is built on top of cURL and have options to set manually needed cURL parameters as we need to.
Let’s make some sample GET request to some ‘https://’
//somecontroller.php
//...
$client = new \Guzzle\Service\Client();
$req = $client->get('https://someurl.com/with_self_signed_certificate');
$response = $req->send();
print_r($response);exit;
//...
It will not be enough yet …
Let’s add two more lines to make it work:
//somecontroller.php
//...
$client = new \Guzzle\Service\Client();
$req = $client->get('https://someurl.com/with_self_signed_certificate');
$req->getCurlOptions()->set(CURLOPT_SSL_VERIFYHOST, false);
$req->getCurlOptions()->set(CURLOPT_SSL_VERIFYPEER, false);
$response = $req->send();
print_r($response);exit;
//...
And that’s it.
Of course, you can set any cURL option that is available and about that you can read here [http://php.net/manual/en/function.curl-setopt.php]
Cheers.


