Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java's keytool command with IP addresses

I'm trying to get an image via an https URL, and am having some problems. I generate a keystore with Java's keytool command. If I specify the common name (CN) equal to my hostname, such as CN=JONMORRA, and then try to query via my hostname, such as https://JONMORRA:8443/ then it works fine. However, if I specify the common name as my ip address, such that CN=192.168.56.1, and try to query via my ip address, such as https://192.168.56.1:8443/ then I get an error

HTTPS hostname wrong: should be <192.168.56.1>

Which is stating that my hostname is wrong, even though that's what I specified in the keystore.

I would like to use ip addresses instead of hostnames so I can query between Linux and Windows boxes without worrying about hostnames.

Why is the CN not accepting ip addresses, and how can I fix it?

Thanks

like image 625
Jon Avatar asked Dec 22 '22 10:12

Jon


1 Answers

To acutally generate a valid certificate using keytool, use:

keytool -keystore keystore.jks -genkey -ext SAN=IP:{IP_ADDRESS}

e.g.:

keytool -keystore keystore.jks -genkey -ext SAN=IP:192.168.1.1
like image 176
Murmel Avatar answered Dec 31 '22 15:12

Murmel