ssl - cURL 说证书已过期,Firefox 不同意

标签 ssl curl openssl

我正在尝试通过 cURL 访问一个内部站点(我几天前就可以访问)。但是,cURL 给出错误 curl: (60) SSL certificate problem: certificate has expired。如果我使用 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);

关于ssl - cURL 说证书已过期,Firefox 不同意,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25047732/

相关文章:

Curl 设置 Content-Type 不正确

c - 使用 OCSP 装订在客户端程序中进行 OpenSSL 证书吊销检查

linux - 支持 FIPS 的 OpenSSL 和 openssl/fips.h : No such file or directory

ssl - erlang 安全 tcp 中的 {active, N} 模式

php - cURL 在 PHP 7 上非常慢,但在 PHP 5 上则不然

image - 带有 SSL 的 Xamarin.Forms Image.Source

curl - ElasticSearch:按索引列出所有文档[未找到 uri 的处理程序]

ssl - 如何使用 openssl 进行 TLS 1.3 PSK?

ruby-on-rails - 带有 CA 证书的 Mongo SSL 配置仅适用于 Rails 控制台,不适用于 Rails 服务器

node.js - Azure 虚拟机上的 Sails.js 部署问题