跳到主要内容
ecdsa.com
OpenSSL CLI (openssl s_client / openssl verify)OpenSSL CLI

错误信息

verify error:num=10:certificate has expired

也可能输出为

  • error 10 at 0 depth lookup: certificate has expired
  • Verify return code: 10 (certificate has expired)

s_client 输出“verify error:num=10:certificate has expired”,随后是“notAfter=…”;openssl verify 输出“error 10 at <depth> depth lookup: certificate has expired”。尚未生效的证书会产生错误 9,即“certificate is not yet valid”。

OpenSSL CLI (openssl s_client / openssl verify) — X509_V_ERR_CERT_HAS_EXPIRED

含义

OpenSSL 错误 10(X509_V_ERR_CERT_HAS_EXPIRED):证书链中某张证书的 notAfter 日期早于验证时间;除非指定了 -attime,验证时间就是本地时钟。与错误一同输出的 depth 行会告诉你是哪张证书:0 是服务器自己的证书,更大的数字是中间证书。

原因

修复方法

  1. 1.

    找出已过期的证书

    查看 depth 行和 notAfter 行;-checkend 可以告诉你证书文件是否会在指定秒数内过期,很适合用于监控。

    bash
    # The depth printed with the error identifies the certificate; s_client also prints notAfter
    echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>&1 | grep -E '^depth|verify error|notAfter'
    # Check a file, and whether it expires within 30 days (exit 1 = yes)
    openssl x509 -in server.pem -noout -enddate -checkend 2592000
  2. 2.

    在指定时间点验证

    openssl verify -attime <unix time> 会显示证书链在那个时刻是否有效,从而把过期与其他错误区分开。

    bash
    # Would the chain verify at another moment? (useful to separate clock problems)
    openssl verify -attime "$(date -d '2025-02-01' +%s)" -CAfile root.pem server.pem
  3. 3.

    续期并重新加载

    为证书续期,重新加载负责终止 TLS 的组件,然后从网络一侧确认新的过期时间。

    bash
    sudo certbot renew && sudo systemctl reload nginx
    echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>/dev/null | openssl x509 -noout -enddate

相关错误

浏览完整的签名错误库