如何在证书替代名称中显示 IP 地址?

问题描述

我在尝试使用本地计算机上的自签名证书建立 TSL 连接时遇到问题。我尝试了文章、stackoverflow 和 github 中的各种示例,但它们通常会失败并显示以下错误消息:

Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: IP: 127.0.0.1 is not in the cert's list:

因此,我尝试将本地 IP 添加到列表替代名称以满足 TLS 握手要求,每个证书和 csr 都将该 IP 包含在替代名称中。

openssl x509 -in root-cert.pem -text -noout

   X509v3 extensions:
        X509v3 Subject Key Identifier: 
            86:0B:0D:C4:32:1D:1E:10:98:1F:0B:17:D1:02:5B:36:D5:D9:21:3C
        X509v3 Authority Key Identifier: 
            keyid:86:0B:0D:C4:32:1D:1E:10:98:1F:0B:17:D1:02:5B:36:D5:D9:21:3C

        X509v3 Basic Constraints: critical
            CA:TRUE
        X509v3 Subject Alternative Name: 
            IP Address:127.0.0.1

openssl req -text -noout -verify -in client.csr

    Attributes:
    Requested Extensions:
        X509v3 Subject Alternative Name: 
            IP Address:127.0.0.1

openssl req -text -noout -verify -in server.csr

    Attributes:
    Requested Extensions:
        X509v3 Subject Alternative Name: 
            IP Address:127.0.0.1

然而,当我尝试建立 TLS 连接(使用标准节点客户端/服务器示例)时,我仍然得到 Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: IP: 127.0.0.1 is not in the cert's list:

如何找出 cert's list 中的内容与证书和请求中包含的内容

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)