58

我们在 amazon ec2 ( backend.abc.com & frontend.abc.com )上运行 2 个应用程序。对于该应用程序,我们使用了付费 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回答)

之后,当我们通过 - 卷曲 abc.com 时curl -v --url https://backend.abc.com --cacert /etc/ssl/ssl.cert/cacert.pem,它工作正常。回应如 -

* Rebuilt URL to: https://backend.abc.com/
*   Trying 127.0.0.1...
* Connected to backend.abc.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: *.abc.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=*.abc.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.abc.com到 backend.abc.com 时,它会抛出这个错误 -

* Rebuilt URL to: https://backend.abc.com/
*   Trying 127.0.0.1...
* Connected to backend.abc.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=*.abc.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.

我的卷曲代码 -

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://backend.abc.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);
4

10 回答 10

50

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

  1. 转到https://whatsmychaincert.com
  2. 测试你的服务器
  3. 如果他们确认您的根证书已过期,请下载并使用没有此证书的 .crt。
于 2020-05-31T11:36:41.480 回答
23

如果您在 Ubuntu 16 系统上遇到“curl”(或类似)问题,我们可以通过以下方式修复它:

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

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

对于 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/

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

于 2020-06-01T10:51:23.867 回答
3

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

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

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

于 2020-05-31T21:23:37.480 回答
2

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

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

但它在网站上不起作用。

解决方案很简单:

只需重新启动 php-fpm :/

最好的祝福,

威利

于 2021-10-01T07:01:49.833 回答
2

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

$ echo "insecure" >> ~/.curlrc

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

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

于 2021-11-11T18:32:12.147 回答
1

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

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

干杯!

于 2020-05-31T22:03:53.027 回答
1

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

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

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

如果您无法重新启动 apache,那么简单的方法就是重新启动您的实例。

于 2020-06-01T10:06:53.180 回答
1

我们遇到了同样的问题,经过一些故障排除后,我们发现 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 证书的结果

于 2020-06-02T16:16:28.467 回答
1

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

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

这是怎么回事:

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

也许它可以帮助你?

于 2020-06-03T16:38:19.687 回答