简体   繁体   English

PHP cURL错误60

[英]PHP cURL error 60

Yes I've seen the many questions about this, in fact I already had this problem and solved it last year. 是的,我已经看到了很多与此有关的问题,实际上我已经遇到了这个问题,并在去年解决了它。 This time for some reason the solution (adding https://curl.haxx.se/ca/cacert.pem ) doesn't work. 这次由于某种原因,解决方案(添加https://curl.haxx.se/ca/cacert.pem )不起作用。

The server (my company's) is a node.js app, I registered the server private key, server crt, and the root and intermediate certificates (I think?), the names are DigiCertCA.crt and TrustedRoot.crt . 服务器(我公司的服务器)是一个node.js应用程序,我注册了服务器私钥,服务器crt以及根证书和中间证书(我认为吗?),名称分别为DigiCertCA.crtTrustedRoot.crt The client is a PHP script making a cURL connection. 客户端是建立cURL连接的PHP脚本。 It had been working fine after I added cacert.pem to php.ini. 在将cacert.pem添加到php.ini之后,它一直运行良好。 Recently my company renewed the SSL certificates, and around the same time the client PHP script (another company's) was moved to a production server from dev. 最近,我的公司更新了SSL证书,并且大约在同一时间,客户端PHP脚本(另一家公司的PHP脚本)从dev移到了生产服务器。 Then the SSL broke again. 然后SSL再次中断。

The website looks fine when opened with chrome (secure https, not broken). 使用chrome(安全的https,未损坏)打开时,网站看起来不错。 Here is the PHP script, simplified to demonstrate the problem. 这是PHP脚本,经过简化以演示该问题。 I tried adding the cacert.pem both through php.ini and curl_setopt, with no success. 我尝试通过php.ini和curl_setopt添加cacert.pem,但没有成功。 This is running on my local development machine, Windows 10 with xampp 5.6.3 这是在我的本地开发计算机上运行的,该计算机带有xampp 5.6.3的Windows 10

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://example.com'); 
curl_setopt($ch, CURLOPT_CAINFO, 'D:/xampp/php/extras/ssl/cacert.pem');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
$content = trim(curl_exec($ch));
if (curl_errno($ch)) {
    $content = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
} 
curl_close($ch);
print $content;

Error message: 错误信息:

60: SSL certificate problem: unable to get local issuer certificate

Additional info: 附加信息:

The error message for the production PHP script is different actually, there it says 生产PHP脚本的错误消息实际上是不同的,它说

curl: (60) Peer's Certificate issuer is not recognized.

I also tried using curl to access other subdomains using my company's certificates and they all give the same error 60. While accessing https://twitter.com is OK 我还尝试使用curl使用我公司的证书来访问其他子域,它们都给出相同的错误60。在访问https://twitter.com可以

you have a mistake I think 我想你有一个错误

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

you have kept this true , so it seems to be the issue 您保持了这一true ,这似乎是问题所在

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

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