Openssl 告诉证书已过期,但尚未过期

标签 openssl certificate

我遇到了 curlopenssl 报告客户端证书已过期的问题,即使它不是将来的日期:

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

但是

# 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

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

为什么会发生这种情况?

最佳答案

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

例如,对于 google,此命令 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

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

notBefore=Oct  6 12:37:54 2016 GMT
notAfter=Dec 29 12:28:00 2016 GMT

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

notBefore=May 21 04:00:00 2002 GMT
notAfter=Aug 21 04:00:00 2018 GMT

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

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

也很容易知道在没有 showcerts 的情况下运行为您提供证书链的清晰 View - 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
---

所有这些都不需要过期。

关于Openssl 告诉证书已过期,但尚未过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24992976/

相关文章:

c - .pem openssl 中证书的十六进制详细信息

scripting - 如何在 "openssl s_client -connect"内强制退出?

ssl - OpenSSL ClientHello 在最新版本中失败

ios Parse APNS 无证书-证书无效

java - SOAP 故障 : No trusted certs found

ssl - 更新 SSL 证书颁发者值

java - OpenSSL 加密 key 和 IV 与 Java 程序生成的不同

certificate - 如何加入苹果开发团队?

ios - 第三方 iOS AppStores(通步、sibche 等)如何对 App 进行签名和安装?

ios - 一台mac创建2个证书