We help IT Professionals succeed at work.

Using HttpUrlConnection to secure server https

hhi
hhi asked
on
I'm tring to use:
url = 'URL address with HTTPS"
url.openConnection()


The server that I'm tring to connect is using "Snake Oil" certificate.

When I invoke this method I get Authorization poblem with the certificate.

When I do the same on SUN , https site I don't have any problem.

Do you know how to solve this issue ?

Thanks,
HHI

Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
What sort of authentication problem?
hhi

Author

Commented:
The following message:

 exception : <untrusted server cert chain>.
Maybe the jvm does not trust the "Snake Oil" certificate. i.E it is not validated by a trusted CA1.
You have to import the "Snake Oil" certificate in to the cacerts.

hhi

Author

Commented:
How do I do it ?
keytool -import -storepass bJt$%100walpUgis -keystore cacerts  -file snakeoil.cer -alias snakeoil

also specify -Djavax.net.ssl.trustStore=cacerts

you find usefull informations at:

http://java.sun.com/products/jsse/doc/guide/API_users_guide.html

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points for Oliver_Dornauf

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venabili
EE Cleanup Volunteer

Explore More ContentExplore courses, solutions, and other research materials related to this topic.