Openssl告知证书已经过期,但尚未过期

Flu*_*ffy 8 openssl certificate

我遇到问题curl并将openssl客户端证书报告为已过期,即使它不是未来的日期:

# echo | openssl s_client -showcerts -connect example.com:443 2>&1 | grep Verify
    Verify return code: 10 (certificate has expired)
Run Code Online (Sandbox Code Playgroud)

# echo | openssl s_client -showcerts -connect example.com:443 2>&1 | openssl x509 -noout -dates
notBefore=Oct 17 00:00:00 2011 GMT
notAfter=Oct 21 12:00:00 2014 GMT
Run Code Online (Sandbox Code Playgroud)

系统日期是正确的.Firefox也没有显示该网站证书的任何错误.我试过的Openssl版本是OpenSSL 1.0.1e-fips 11 Feb 2013OpenSSL 1.0.1f 6 Jan 2014.我在这里找到了一个类似的问题,其中作者声称openssl 0.9.8中缺少该问题,但在1.0.1中存在.

为什么会这样?

Flu*_*ffy 12

我的问题是证书确实过期了,但不是这个特定的,而是签名链中的一个。

例如,对于谷歌这个命令openssl s_client -showcerts -connect google.com:443 </dev/null | openssl x509 -noout -dates显示:

notBefore=Oct  6 12:37:54 2016 GMT
notAfter=Dec 29 12:28:00 2016 GMT
Run Code Online (Sandbox Code Playgroud)

但是只openssl s_client -showcerts -connect google.com:443 </dev/null显示了不是 1,而是 3 个证书(附在---BEGIN/END CERTIFICATE---部分中),第一个是 google 的,它是实际检查的那个。为了验证这一点,我已经复制了(可能应该有更少的手动方式)第一个 to/tmp/google和最后一个 to /tmp/geotrust,现在运行openssl x509 -noout -dates < /tmp/google给了我:

notBefore=Oct  6 12:37:54 2016 GMT
notAfter=Dec 29 12:28:00 2016 GMT
Run Code Online (Sandbox Code Playgroud)

与第一个命令的输出匹配,并且openssl x509 -noout -dates < /tmp/geotrust

notBefore=May 21 04:00:00 2002 GMT
notAfter=Aug 21 04:00:00 2018 GMT
Run Code Online (Sandbox Code Playgroud)

这是不同的,以前没有显示过。所以最后我的问题是,其中一个更高权限的证书确实已经过时了。

顺便说一句,问题的评论建议升级操作系统来解决这个问题——我想原因是一样的。操作系统带有一堆根证书,所以如果你有疯狂的旧操作系统,其中一些可能会过期,你可以升级这些根证书,或者整个操作系统来解决这个问题。

也很方便地知道,在没有的情况下运行可以showcerts让您很好地了解证书链 - openssl s_client -connect google.com:443 </dev/null

---
Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.google.com
   i:/C=US/O=Google Inc/CN=Google Internet Authority G2
 1 s:/C=US/O=Google Inc/CN=Google Internet Authority G2
   i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
 2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
   i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
Run Code Online (Sandbox Code Playgroud)

所有这些都不需要过期。


Vic*_*ang 6

我今天也遇到了类似的问题,特意来这里寻找答案。幸运的是,我自己得到了答案。这是我得到它的方法:

  1. 当我在一个盒子上收到“验证返回代码:10(证书已过期)”错误时,我尝试了另一个盒子,但没有针对同一个 SSL 站点收到错误,这实际上是“验证错误:num=20:无法获取本地颁发者证书”(我可以接受)
  2. 然后我认为根本原因应该在第一个看到该错误的框中。最可能的原因可能是信任存储中存在一些不同的 CA 证书,尽管我仍然不知道第一个盒子在哪里
  3. 为了获取影响证书验证的文件,我在“openssl s_client ...”之前添加了“strace”,并仔细阅读大输出区域中显示的文件,特别是“验证返回代码:10(证书有已过期)”错误。我收到 2 个可疑文件
  4. 我运行“openssl x509 -text -in {filename}”来验证这两个文件,并成功确认其中一个文件是根本原因,因为它已过期。这是中级证书

话虽如此,请检查本地信任存储中是否有任何已过期的中间/根证书(对于 openssl 可能是 /usr/lib/ssl/certs/ ),这会“毒害” openssl 客户端命令或curl 的验证命令。