Reputation: 21
I a new to this ssl handshaking but I am having a linux server when i am curling a https end point I am getting the response(ssl verification is done) however when i am connecting via java it fails with the following error
Caused by: java.io.IOException: HTTPS hostname wrong: should be <hostname>
at sun.net.www.protocol.https.HttpsClient.checkURLSpoofing(HttpsClient.java:649)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:573)
i am using java version 8
Upvotes: 0
Views: 1310
Reputation: 766
When you access your HTTPS server from curl - it also performs server identity check. Java HTTPS client does similar check. The hostname in the URL of HTTPS server must be identical to HTTPS server's certificate CN RDN of the Subject attribute or DNS name of SubjectAlternativeName (SAN) extension.
I found some info here.
Example for the URL https://mycompany.com
Good certificate: CN=mycompany.com or SAN DNS=mycompany.com
Bad certificate: CN=aaa.bbb.mycompany.com
Upvotes: 1