OpenSSL 证书到期

信息安全 tls openssl x.509
2021-08-29 00:40:54

我正在尝试使用 OpenSSL 来验证 SSL 证书是否仍然有效,但我不断收到奇怪的结果。我正在测试的示例站点 (expired.badssl.com) 的 SSL 证书已过期。

Firefox 将此标记为 2015 年 4 月过期并显示相关警告,但是当我查看使用 OpenSSL s_client 提供的证书信息时,它说它在 2016 年之前仍然有效:

$ (echo "" | openssl s_client -connect expired.badssl.com:443 -CApath /etc/ssl/certs/ca-certificates.crt) | openssl x509 -noout -dates
[...]
depth=0 OU = Domain Control Validated, OU = PositiveSSL Wildcard, CN = *.badssl.com
verify return:1
DONE
notBefore=Apr  9 00:00:00 2015 GMT
notAfter=Jul  7 23:59:59 2016 GMT

我怀疑我在这里遗漏了一些东西,但我无法弄清楚它是什么。

1个回答

我想你不见了 -servername expired.badssl.com

$ echo "" | openssl s_client -connect expired.badssl.com:443 -CApath /etc/ssl/certs/ca-certificates.crt -servername expired.badssl.com 2>/dev/null | openssl x509 -noout -subject -dates

subject= /OU=Domain Control Validated/OU=PositiveSSL Wildcard/CN=*.badssl.com  
notBefore=Apr  9 00:00:00 2015 GMT  
notAfter=Apr 12 23:59:59 2015 GMT

显然这个服务器托管了几个 HTTPS 服务......

$ host badssl.com
badssl.com has address 104.154.89.105

$ host expired.badssl.com
expired.badssl.com has address 104.154.89.105

...因此,必须使用服务器名称指示扩展才能获得适当的证书,而不是与默认站点对应的证书。