duanjuelu8874 2015-01-21 03:43
浏览 1364

如何在Guzzle 5中忽略无效的SSL证书错误

This should be an easy thing to do. I can find plenty of references to how to do it in Guzzle 3, but they don't work in Guzzle 5.

What I am doing so far:

$this->client = new GuzzleClient(['defaults' => [
    'verify' => 'false'
]]);

When I send a request though I get this error:

RequestException in RequestException.php line 51:
SSL CA bundle not found: false

I cannot find any useful reference to this error on google. If I could get access to the curl options then I could try something like the solution suggested here (which is for Guzzle 3, hence why it doesn't work): http://inchoo.net/dev-talk/symfony2-guzzle-ssl-self-signed-certificate/, the relevant section of which is:

$req->getCurlOptions()->set(CURLOPT_SSL_VERIFYHOST, false);
$req->getCurlOptions()->set(CURLOPT_SSL_VERIFYPEER, false);
  • 写回答

3条回答 默认 最新

  • dqwd71332 2015-02-21 11:22
    关注

    You should use

    $this->client = new GuzzleClient(['defaults' => [
        'verify' => false
    ]]);
    

    i.e. a Boolean false, not the string 'false'

    The documentation is here: http://guzzle.readthedocs.org/en/latest/clients.html#verify

    评论
  • dsaeyrq451928 2016-07-15 12:33
    关注

    Try with updated version that works:

    $this->client = new GuzzleClient(['base_uri' => 'https://api.example.com/', 'verify' => false ]);
    

    or a more simple version:

        $this->client = new GuzzleClient(['verify' => false ]);
    

    Tested with version 6.2-dev.

    评论
  • douba2705 2018-06-14 22:42
    关注

    The actual version is the correct one:

    $this->client = new GuzzleClient(['verify' => false ]);
    

    At 2018, this does not work:

    $this->client = new GuzzleClient(['defaults' => [
        'verify' => false
    ]]);
    
    评论
编辑
预览

报告相同问题?

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

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

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

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

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

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

客服 返回
顶部