【问题标题】:Curl cannot verify wildcard SSL certificate issued by VerisignCurl 无法验证 Verisign 颁发的通配符 SSL 证书
【发布时间】:2015-05-12 05:37:32
【问题描述】:

我有一个脚本需要使用 cURL 安全地连接到网站 foo.bar.com,该网站由 *.bar.com 的通配符 SSL 证书覆盖。

通配符证书由威瑞信颁发,所有浏览器都信任它,没有任何问题。但是,我无法让 PHP / cURL 进行连接(至少在不禁用证书验证的情况下不会)。

只是为了隔离问题,我尝试仅使用命令行 cURL(版本 7.21.1)进行连接。我从 Mozilla 下载了一个更新的 CA 包(保存为 cacert.pem),然后运行:

curl --cacert /path/to/cacert.pem "https://foo.bar.com"

结果是:

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

我一直在谷歌上搜索并阅读有关此错误的帖子,但似乎无处可去。

如果我尝试任何普通的非通配符证书域,它似乎工作得很好,所以它似乎本地化为这个特定的通配符证书问题。我什至手动导出了信任链中的所有证书,并手动将它们添加到 cacert.pem 文件中(只是为了查看 CA 包是否缺少某些内容),但仍然没有。

最终,我想在 PHP cURL 中使用它,但我认为如果我可以确定命令行 cURL 的问题,那么该解决方案也可能适用于 PHP 脚本。

【问题讨论】:

    标签: php ssl curl https


    【解决方案1】:

    问题可能不是 curl,而是由于缺少链证书,导致信任链不完整。桌面浏览器在这方面的问题较少,因为它们在访问其他网站时会缓存此类证书,并且某些浏览器甚至会下载丢失的证书。

    转到SSLLabs 并检查该站点。注意“链问题”。

    如果我的回答有误,请添加相关网址以及您使用的 curl 版本,以便仔细查看。

    【讨论】:

    • 正如我所提到的,我已经手动导出了链中的根 CA 和中间 CA 证书(直接从 Windows,证书查看器确认链正常)并将它们放入自己的 PEM-格式化文件(首先是中间 CA,然后是根 CA)。然后我将 cURL 指向该文件,它可以很好地加载文件(它会告诉你它是否无法读取文件),但它仍然无法验证。 SSLLabs 指出“Chain Issues”中唯一的问题是“Extra Certs”。
    • 我使用的curl版本(7.35.0)在这个主机上没有问题。我尝试过的版本 7.19.7 也没有。因此,问题可能出在您正在使用的 cacert.pem 中。
    • 刚刚关闭它。去年我无法让它工作,但我现在重试了它,它工作了。不知道为什么 - 可能他们的证书已更新,或者可能是使用的 OpenSSL 版本存在问题。
    • " 寻找“链问题” " 谢谢它有效!。我通过浏览器查看证书菜单下载 mydomain-chain.pem 文件,然后将其保存在 /etc/ssl/certs/ 目录中,然后在 /etc/apache2/sites-enabled/mydomain.https.conf 中设置链路径,然后重启apache2。现在 curl 可以工作了:D 再次感谢
    猜你喜欢
    • 2016-10-30
    • 1970-01-01
    • 2021-05-11
    • 2021-05-24
    • 2017-07-19
    • 2019-09-03
    相关资源
    最近更新 更多