0

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

tarun14110
  • 940
  • 5
  • 26
  • 57
  • 2
    Could you provide more details about the certificate. Notably an IP address in subjectAltNames should be of type IP and not DNS. – Steffen Ullrich Apr 22 '19 at 18:43
  • @SteffenUllrich yeah, its of type DNS. I have added more details. How could I change it to type IP? – tarun14110 Apr 22 '19 at 19:03
  • 3
    You cannot change an existing certificate. You would need to create a new certificate where you specify the type of the subjectAltNames entry as IP and not DNS. – Steffen Ullrich Apr 22 '19 at 19:36

1 Answers1

0

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
)
tarun14110
  • 940
  • 5
  • 26
  • 57