10

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?

TheStoryCoder
  • 3,403
  • 6
  • 34
  • 64
  • Have you had a look at the other options for `verify`, like documented at https://guzzle.readthedocs.io/en/stable/request-options.html#verify? – Nico Haase Apr 12 '19 at 11:48

1 Answers1

14

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

Peter
  • 29,454
  • 5
  • 48
  • 60