问题
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