繁体   English   中英

cURL 错误60:SSL 证书问题:证书已过期

[英]cURL error 60: SSL certificate problem: certificate has expired

我们在亚马逊 EC2 上运行 2 个应用程序( backend.example.comfrontend.example.com )。 对于该应用程序,我们使用了付费的 SSL 证书。 该证书到期日期为2021 年 6 月 但是今天,我们遇到了一个错误——

cURL error 60: SSL certificate problem: certificate has expired (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

我们检查证书到期日期,但没有问题( 2021 年 6 月)。 然后我们按照这个线程 - curl: (60) SSL 证书问题:无法获得本地颁发者证书(@Dahomz 回答)

After that, when we curl example.com by - curl -v --url https://backend.example.com --cacert /etc/ssl/ssl.cert/cacert.pem , It working fine. 回应如 -

* Rebuilt URL to: https://backend.example.com/
*   Trying 127.0.0.1...
* Connected to backend.example.com (127.0.0.1) port 443 (#0)
* found 139 certificates in /etc/ssl/ssl.cert/cacert.pem
* found 600 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ******_RSA_***_***_GCM_*****
*    server certificate verification OK
*    server certificate status verification SKIPPED
*    common name: *.example.com (matched)
*    server certificate expiration date OK
*    server certificate activation date OK
*    certificate public key: RSA
*    certificate version: #3
*    subject: OU=Domain Control Validated,OU=PositiveSSL Wildcard,CN=*.example.xyz
*    start date: Mon, 04 May 2019 00:00:00 GMT
*    expire date: Wed, 07 June 2021 23:59:59 GMT
*    issuer: C=GB,ST=Greater Manchester,L=Salford,O=Sectigo Limited,CN=Sectigo RSA Domain Validation Secure Server CA
*    compression: NULL
* ALPN, server accepted to use http/1.1

但是当我们通过 curl 从frontend.example.combackend.example.com时,它会抛出这个错误 -

* Rebuilt URL to: https://backend.example.com/
*   Trying 127.0.0.1...
* Connected to backend.example.com (127.0.0.1) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/ssl.cert/cacert.pem
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / *****-RSA-*****-GCM-******
* ALPN, server accepted to use http/1.1
* Server certificate:
*    subject: OU=Domain Control Validated; OU=PositiveSSL Wildcard; CN=*.example.com
*    start date: Mar  4 00:00:00 2019 GMT
*    expire date: Apr  7 23:59:59 2021 GMT
*    issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*    SSL certificate verify result: certificate has expired (10), continuing anyway.

我的 curl 代码 -

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://backend.example.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, fopen(public_path("c.log"), 'w'));
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$output = curl_exec($ch);
$error = curl_error($ch);
$info = curl_getinfo($ch);
curl_close($ch);

要解决此问题,请从您的域证书中删除过期的根证书。

  1. Go 到https://whatsmychaincert.com
  2. 测试你的服务器
  3. 如果他们确认您的根证书已过期,请下载并使用没有此证书的.crt。

如果您在 Ubuntu 16 系统上遇到“卷曲”(或类似问题)问题,以下是我们修复它的方法:

在 Ubuntu 16 系统托管 curl / 应用程序失败:

  • 纳米 /etc/ca-certificates.conf
  • 删除指定 AddTrust_External_Root.crt 的行(或注释)
  • apt update && apt install ca-certificates
  • 更新 CA 证书 -f -v
  • 使用之前失败的 URL 再次尝试 curl - 希望它现在可以工作:)

对于 ubuntu 14.04

打开你的终端

sudo su
wget https://support.sectigo.com/Com_KnowledgeDetailPage?Id=kA01N000000rfBO -O SHA-2_Root_USERTrust_RSA_Certification_Authority.crt --no-check-certificate
cp SHA-2_Root_USERTrust_RSA_Certification_Authority.crt /usr/share/ca-certificates/mozilla/

然后dpkg-reconfigure ca-certificates取消选中 mozilla/AddTrust_External_Root.crt并检查mozilla/2_Root_USERTrust_RSA_Certification_Authority.crt
或运行sudo update-ca-certificates取消选中这些。

您可以启用insecure连接,将此选项添加到您的$HOME/.curlrc文件:

$ echo "insecure" >> ~/.curlrc

不建议永久保留它,但是,对于快速和临时的解决方案,这是一个不错的选择。

参考: 如何应用所有 HTTPS 连接的更改

您的信任库似乎未使用最新的受信任根更新。 了解它从昨天 5 月 30 日开始发生在你身上。 我假设您将 Sectigo 作为您的 CA。

更新您的信任,您应该能够连接。

https://support.sectigo.com/articles/Knowledge/Sectigo-AddTrust-External-CA-Root-Expiring-May-30-2020

昨天我遇到了@finesse 上面报告的问题。 由于在我们的系统上,ca-certificates 会自动更新,因此我很困扰,因为证书是有效的

  • 在命令行上使用 curl
  • 使用带有 php-cli 的 php 脚本

但它在 web 站点上不起作用。

解决方案很简单:

只需重新启动 php-fpm:/

此致,

威利

永久的解决方案是从您的提供商重新颁发 SSL 证书并将其重新安装到您的服务器上。

重新颁发的证书将更新 CA 包。

干杯!

我们有同样的错误。 为了解决您的问题,请使用您信任的 SSL 站点的最新版本更新您的“SSLCertificateChainFile”。 在我们的例子中是comodo。

您需要 go 到您信任的站点,并在您的证书下找到“CA-CRT”。 复制内容。

  1. Go 到您的 /etc/apache2/sites-available
  2. 找到带有“SSLCertificateChainFile”的行。
  3. 接下来编辑文件并将内容替换为新的 CA-CRT 值。
  4. 然后重启你的 web 服务器,在我们的例子中是 apache: service apache2 restart or systemctl restart Z974318ED5C13640BFBCC536

如果您无法重启 apache,简单的方法是重启您的实例。

我们遇到了同样的问题,经过一些故障排除后,我们发现 COMODO 的根证书已过期。

Valid until Sat, 30 May 2020 10:48:38 UTC (expired 3 days, 5 hours ago) EXPIRED

我们通过以下方式对此进行了测试: https://www.ssllabs.com/ssltest/index.html 我们通过从经销商处下载新证书解决了这个问题。

这是我们收到的关于 COMODO 证书的结果

我必须在基于 debian 的服务器上解决此问题

这是由于系统使用了 openssl(卷曲取决于 openssl)

这是怎么回事:

  1. 从系统中删除 AddTrust_External_Root.crt(通常在/etc/ssl/certs中找到)
    1. /etc/ca-certificates.conf中删除或注释“mozilla/AddTrust_External_Root”行
    2. 运行sudo update-ca-certificates更新 openssl 使用的证书

也许它可以帮助你?

更改或编辑以下设置:

从客户域 SSL 中的服务器更改这些文件

服务器密钥= 服务器密钥是服务器使用的私有加密/解密密钥。

中间证书 (CA) = 证书颁发机构 (CA) 是颁发数字证书的实体,该证书将通过证书的命名主体验证公钥的所有权。

域证书= 域证书是由证书颁发机构提供的电子文档,用于检查申请人使用特定域名的许可。

我设法通过在我的服务器上运行更新来解决问题:

sudo yum update

这似乎解决了 curl 证书的任何问题。

sudo update-ca-certificates

修复了我的问题

暂无
暂无

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

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