Exception on using IP address in certificate name

拜拜、爱过 提交于 2020-01-06 08:16:34

问题


Caused by: javax.net.ssl.SSLPeerUnverifiedException: Hostname 97.xx.xxx.xxx not verified: certificate: sha256/tjx1IRiuC1TmxlIIhW8FWOxoaFoY2E3mECOgtGW0Jqk= DN: O=Internet Widgits Pty Ltd, ST=Some-State, C=AU subjectAltNames: [97.xx.xxx.xxx]

Certificate details

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            XXXXXXX
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = US, ST = Some-State, O = Internet Widgits Pty Ltd
        Validity
            Not Before: Apr 22 17:42:36 2019 GMT
            Not After : Apr 20 17:42:36 2024 GMT
        Subject: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    XXXXX
                Exponent: XXX
        X509v3 extensions:
            X509v3 Authority Key Identifier: 
                keyid:XXXXX

            X509v3 Basic Constraints: 
                CA:FALSE
            X509v3 Key Usage: 
                Digital Signature, Non Repudiation, Key Encipherment, Data Encipherment
            X509v3 Subject Alternative Name: 
                DNS:97.XX.XXX.XXX
    Signature Algorithm: sha256WithRSAEncryption
         XXXXXX

I am getting the above error on using the certificate with IP address. Is there something else I am supposed to do for creating a certificate with Ip address? What are the reasons for the Hostname not verified: exception


回答1:


I was able to get it to work as suggested by Steffen in the comments, I added the domain IP address to subjectAltName with type IP.

openssl x509 -req -in certificate_sign_req.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial -out signed_certificate.crt -days 1825 -sha256 -extfile <(cat <<EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
IP.1 = ${domain}
EOF
)


来源:https://stackoverflow.com/questions/55799371/exception-on-using-ip-address-in-certificate-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!