如何解决 cURL 错误 60:Laravel 5 中的 SSL 证书?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30402280/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:36:29  来源:igfitidea点击:

How solve cURL error 60: SSL certificate in Laravel 5?

phplaravel

提问by Rashed Shaon

I'm using "FriendsOfPHP/Goutte" Package https://github.com/FriendsOfPHP/GoutteFor web crawling... When I use "http://" links then it's ran correctly but when I use "https://" then show the following errors...

我正在使用“FriendsOfPHP/Goutte”包https://github.com/FriendsOfPHP/Goutte用于网络爬虫......当我使用“http://”链接时,它运行正确,但是当我使用“https://”时"然后显示以下错误...

2/2 RequestException in RequestException.php line 51:
cURL error 60: SSL certificate problem: unable to get local issuer certificate

RequestException.php 第 51 行中的 2/2 RequestException:
cURL 错误 60:SSL 证书问题:无法获取本地颁发者证书

回答by Harry Geo

I think you have a certificate problem. It seems Gouttedepends on Guzzle 4. And Guzzle can't find the proper certificate to verify a secure httpsrequest, see more about it here.

我认为您有证书问题。这似乎Goutte取决于Guzzle 4. 而且 Guzzle 找不到正确的证书来验证安全https请求,请在此处查看更多相关信息。

Try to download this file: Bundle of CA Root Certificates. (Openand Save As).

尝试下载此文件:Bundle of CA Root Certificates。(OpenSave As)。

Then locate your php.ini file and add,or edit if it already exists, this line

然后找到你的 php.ini 文件并添加或编辑它是否已经存在,这一行

curl.cainfo = "[pathtothisfile]\cacert.pem"

curl.cainfo = "[pathtothisfile]\cacert.pem"

回答by Bogdan

Try disabling CURLOPT_SSL_VERIFYPEERto stop cURL from verifying the peer's certificate:

尝试禁用CURLOPT_SSL_VERIFYPEER以阻止 cURL 验证对等方的证书:

$client->getClient()
       ->setDefaultOption('config/curl/' . CURLOPT_SSL_VERIFYPEER, false);