跳到主要内容
ecdsa.com
GNU Wget built with GnuTLS (Debian)curl

错误信息

ERROR: The certificate of 'api.example.com' has expired.

使用 GnuTLS 构建的 wget 会在通用的“ERROR: The certificate of '<host>' is not trusted.”之后、“The certificate has expired”之前打印这一行。使用 OpenSSL 构建的 wget 则打印“ERROR: cannot verify <host>'s certificate, issued by '…':”,接着是“Issued certificate has expired.”。

含义

按这台机器的时钟,服务器的证书(或其证书链中的另一张证书)已经超过了 notAfter 日期,因此 wget 的 GnuTLS 后端拒绝连接。CA 是受信任的,只是有效期检查未通过。wget 以退出状态 5 退出。

原因

修复方法

  1. 1.

    检查实际提供的证书上的日期

    将 notAfter 与当前 UTC 时间对比。如果服务器提供的是旧证书,而更新的证书已经存在,说明服务器还没有加载新证书。

    bash
    echo | openssl s_client -connect api.example.com:443 -servername api.example.com 2>/dev/null \
      | openssl x509 -noout -subject -startdate -enddate
  2. 2.

    续期并重新加载

    通过 ACME 客户端或 CA 续期,然后重新加载为该名称终止 TLS 的每一个服务;把这两步都自动化,下一次续期就不必依赖有人记得去做。

    bash
    sudo certbot renew --cert-name api.example.com
    sudo systemctl reload nginx     # or apache2 / haproxy: reload whatever terminates TLS
  3. 3.

    校正客户端时间

    如果从另一台机器检查时证书有效,就在出错的那台机器上启用 NTP。

    bash
    date -u
    timedatectl status
    sudo timedatectl set-ntp true

相关错误

浏览完整的签名错误库