跳到主要内容
ecdsa.com
GNU Wget (GnuTLS build); the alias is the OpenSSL build's wordingcurl

错误信息

The certificate's owner does not match hostname 'api.example.com'

也可能输出为

  • ERROR: no certificate subject alternative name matches

使用 GnuTLS 构建的 wget 打印这一行;使用 OpenSSL 构建的版本则打印“ERROR: no certificate subject alternative name matches”,下一行接着是“requested host name '<host>'.”。其中的主机就是你 URL 中的主机。

含义

证书通过了验证,但它是为 URL 中主机以外的其他名称签发的,因此 wget 停止运行。主机会与证书的主题备用名称扩展中的 DNS 名称比较,如今所有 CA 都把证书覆盖的名称放在这个扩展里。wget 以退出状态 5 退出。

原因

修复方法

  1. 1.

    列出证书覆盖的名称

    将 subjectAltName 条目与 URL 中的主机对比。

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

    重新签发证书,补上缺失的名称

    把客户端使用的每个主机名都加入证书请求,然后部署并重新加载。

    bash
    sudo certbot certonly --nginx -d example.com -d www.example.com -d api.example.com
  3. 3.

    使用证书中列出的名称

    如果服务器可以通过某个已列出的名称访问,就在 URL 中使用该名称,而不是 IP 地址或别名。

    bash
    # Download through a name the certificate lists, not an IP or alias
    wget https://www.example.com/file.tar.gz

相关错误

浏览完整的签名错误库