my dog learned polymorphism
The moose likes Sockets and Internet Protocols and the fly likes SSL - client side - trusting untrusted certificates? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "SSL - client side - trusting untrusted certificates?" Watch "SSL - client side - trusting untrusted certificates?" New topic

SSL - client side - trusting untrusted certificates?

Ivan Jouikov
Ranch Hand

Joined: Jul 22, 2003
Posts: 269
Basically I have a web-based spider, that works just like any other spider. One problem though � it won�t spider SSL pages that have untrusted certificates. So I was thinking of a good way to make it trust ALL the certificates (since it uses the URL class to read the pages)

So, I researched it and found an �old-fashioned� way to do this � by overriding TrustManager, and making it trust everything, and saving it in SSLContext or something. Basically, it would look like this:


Custom socket factory:

And here�s the sample code that I would use to test this:

The only �real� piece here is the �Security.setProperty�, which sort of replaces default socket factory with my crappy implementation.

I believe this used to work back on 1.4.2, but I am running 1.5, and here�s the problem that I get when executing the following code:

Any thoughts on how I could fix the �HttpsClient� to make it accept invalid certificates? Going back to 1.4.2 is not an option�

Thanks in advance for your help.

Best Regards,

Ivan V. Jouikov
(206) 228-6670
I agree. Here's the link:
subject: SSL - client side - trusting untrusted certificates?
It's not a secret anymore!