简体   繁体   English

CURL:SSL证书失败,请验证CA证书是否正常

[英]CURL: SSL certificate fails, verify that the CA cert is OK

I am running a local XAMPP server on a windows machine. 我在Windows计算机上运行本地XAMPP服务器。

From this server I am trying to connect to an SSL encrypted page via CURL. 从这台服务器,我试图通过CURL连接到SSL加密页面。

I did run into the following error: 我确实遇到了以下错误:

SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

I realize that I could simply disable SSL verification by using... 我意识到我可以通过使用...简单地禁用SSL验证。

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

..but I really don´t want to do this, that´s the point of using SSL. ..但我真的不想这样做,这就是使用SSL的重点。

I´ve seen several answers here that point to to set the CURL Option "CURLOPT_CAINFO" to a .pem file that can be acquired here: http://curl.haxx.se/ca/cacert.pem 我在这里看到了几个答案,这些答案指向将CURL选项“ CURLOPT_CAINFO”设置为可在此处获取的.pem文件: http : //curl.haxx.se/ca/cacert.pem

curl_setopt($ch, CURLOPT_CAINFO, 'C:\xampp\cacert.pem' );

I did put the file in the given folder, and run the above command before running curl_exec. 我确实将文件放在给定的文件夹中,并在运行curl_exec之前运行上述命令。 But I still get the same error as before. 但是我仍然得到和以前一样的错误。

I also tried to download the certificate from the site that I am trying to connect with, but the error message is still the same. 我还尝试从尝试连接的站点下载证书,但是错误消息仍然相同。

PHP can access the .pem file, with file_get_contents for example, so it does not appear to be a file access / permission problem. PHP可以访问.pem文件,例如使用file_get_contents,因此它似乎不是文件访问/权限问题。

What could be the cause for this problem to persist? 该问题持续存在的原因可能是什么?

I am running: 我在跑步:

  • PHP Version: 5.2.9 PHP版本:5.2.9
  • cURL Information: libcurl/7.16.0 OpenSSL/0.9.8i zlib/1.2.3 cURL信息:libcurl / 7.16.0 OpenSSL / 0.9.8i zlib / 1.2.3

Tardy response but I had same problem and the way I fixed it was to upgrade to php 5.3. 迟到的响应,但我遇到了同样的问题,而解决问题的方法是升级到php 5.3。 I have seen nothing that explicit that says "5.2 does not do proper certificate validation" but you have everything right by using CURLOPT_CAINFO. 我没有看到任何明确的内容说“ 5.2无法正确进行证书验证”,但是使用CURLOPT_CAINFO可以使您一切正常。 Upgrade to 5.3 and it will work. 升级到5.3,它将起作用。

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

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