dongsha2792 2019-04-12 03:45
浏览 255
已采纳

让Guzzle信任自签名证书?

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?

  • 写回答

1条回答 默认 最新

  • dongmaomou4117 2019-04-12 03:49
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部