CURL无法加载https资源; NSS错误-8181

时间:2017-11-30 15:05:14

标签: curl https

当我在CentOS 6(和7)上发现奇怪的卷曲行为时,我一直在尝试配置新的专用服务器:

curl "https://google.com"

返回

curl (60): Peer certificate cannot be authenticated with known CA certificates

似乎curl对当前系统上安装的CA一无所知。

# curl https://google.com --verbose
* About to connect() to google.com port 443 (#0)
*   Trying 172.217.25.174... connected
* Connected to google.com (172.217.25.174) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* Remote Certificate has expired.
* NSS error -8181
* Closing connection #0
* Peer certificate cannot be authenticated with known CA certificates
curl: (60) Peer certificate cannot be authenticated with known CA certificates
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.

--insecure对我不好。

我试图:

  • 重新安装ca-certificates
  • 通过update-ca-trust extract
  • 提取证书
  • 下载第三方ca证书
  • 甚至设置--cacert选项直接卷曲执行

但它对我没有帮助。

首先想到 - 好吧,新的操作系统不能有实际版本的证书,但是如果我yum update -y怎么办?应该是实际的,不应该吗?

我已经检查了以前问过的问题,例如get-60-error-with-curl和其他许多问题。

1 个答案:

答案 0 :(得分:1)

唯一能让我知道的是 - * Remote Certificate has expired.来自卷曲执行的详细回复。

google的证书如何处于过期状态?现在几点了?

糟糕:

# date
Friday, 10 May 2015 12:35:21 -0400

但现在是11/30/2017。

好,

sudo yum install ntp ntpdate -y

然后你必须检查/etc/ntpd.conf,如果它不存在:

sudo su
echo "server 0.pool.ntp.org" > /etc/ntpd.conf && service ntpd start

并检查:

# date
Thursday, 30 November 2017 14:03:35 +0000

不要忘记设置本地时间,例如UTC时间:

sudo mv /etc/localtime /tmp/localtime.bak
sudo ln -s /usr/share/zoneinfo/UTC /etc/localtime

P.S。有关ntp配置的更多信息,您可以获得here