简体   繁体   English

使Guzzle信任自签名证书?

[英]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. 使用Guzzle HTTP客户端,我知道您可以设置new GuzzleClient(['verify' => false])使其不检查证书,例如。 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? 但是,如何使它接受并信任特定的自签名证书,以使您不仅可以使用任何一个证书,还可以只使用一个特定的证书?

A self-signed certificate is its own authority, so simply set the verify option to the filename of the certificate: 自签名证书是其自身的权限,因此只需将verify选项设置为证书的文件名:

// 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 http://docs.guzzlephp.org/en/stable/request-options.html#verify-option

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM