如何在Guzzle 5中忽略无效的SSL证书错误 [英] How to ignore invalid SSL certificate errors in Guzzle 5

查看:741
本文介绍了如何在Guzzle 5中忽略无效的SSL证书错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是一件容易的事.我可以在Guzzle 3中找到很多有关如何执行此操作的参考,但是它们在Guzzle 5中不起作用.

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

我在Google上找不到任何对此错误有用的参考.如果我可以使用curl选项,那么可以尝试类似此处建议的解决方案(适用于Guzzle 3,因此为什么它不起作用):

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);

推荐答案

您应该使用

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

即布尔值false,而不是字符串'false'

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

文档在这里: http://docs.guzzlephp.org/en/latest/request- options.html#verify

这篇关于如何在Guzzle 5中忽略无效的SSL证书错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆