ssl – cURL表示证书已过期,Firefox不同意

我正在尝试通过cURL访问内部网站(几天前我可以访问).但是,cURL给出了错误curl:(60)SSL证书问题:证书已过期.如果我使用openssl来检查证书的开始和结束日期,它会给出一个我很好的时间范围:

echo | openssl s_client -connect internalsite.example.com:443 2>/dev/null | openssl x509 -noout -dates
notBefore=Nov 30 00:00:00 2012 GMT
notAfter=Mar 30 12:00:00 2016 GMT
# For reference, the day I'm posting this is July 30th, 2014

此外,如果我在另一台计算机上使用cURL,或通过浏览器(Firefox,Chrome或IE)连接,我可以毫无错误地连接.

另外,我无法在自己的计算机上连接任何版本的cURL;这包括Cygwin中的cURL和虚拟机内Ubuntu上的cURL,以及Windows版本.

什么可能导致这种行为?

最佳答案 您的证书包可能已过期.

您可以在http://curl.haxx.se/ca/cacert.pem获得由curl开发人员维护的一个

要使用它:

<?
$ch = curl_init("http://example.com");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, '/path/to/cacert.pem');
$response = curl_exec($ch);
点赞