跳到主要内容
ecdsa.com
rustls 0.23 (via reqwest, ureq, hyper-rustls)Rust

错误信息

invalid peer certificate: certificate expired: verification time

完整形式为:“invalid peer certificate: certificate expired: verification time <unix> (UNIX), but certificate is not valid after <unix> (<n> seconds ago)”。早期的 rustls 版本只打印变体名称(“invalid peer certificate: Expired”)。尚未生效的证书会产生另一个变体“not valid yet”。

rustls 0.23 (via reqwest, ureq, hyper-rustls) — CertificateError::ExpiredContext

含义

rustls 验证了证书链,但其中有一张证书在验证时刻已超过其 notAfter 日期。rustls 0.23 会以 Unix 时间戳给出这两个时刻,并说明证书在多少秒前过期,由此可以立即判断出错的是证书还是时钟。

原因

修复方法

  1. 1.

    转换时间戳

    date -u -d @<seconds> 可以把这两个值转换为可读的 UTC 时间。

    bash
    # The message gives both instants as Unix seconds
    date -u -d @1743465600      # certificate's notAfter
    date -u                     # this machine's time
  2. 2.

    续期并重新部署

    续期服务器证书,重新加载服务,然后从网络一侧确认新的到期日期。

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

相关错误

浏览完整的签名错误库