Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Guzzle trust self-signed certificate?

With Guzzle HTTP client I know you can set new GuzzleClient(['verify' => false]) to have it not check the certificate, eg. when you are using a self-signed certificate. But how can I make it accept and trust a specific self-signed certificate, so that you don't just open up for ANY certificate but only one specific one - is that possible?

like image 881
TheStoryCoder Avatar asked Mar 05 '23 04:03

TheStoryCoder


1 Answers

A self-signed certificate is its own authority, so simply set the verify option to the filename of the certificate:

// Use a custom SSL certificate on disk.
new GuzzleClient(['verify' => '/path/to/self-signed/cert.pem']);

http://docs.guzzlephp.org/en/stable/request-options.html#verify-option

like image 86
Peter Avatar answered Mar 25 '23 00:03

Peter