wood burning stoves*
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


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "SSL - client side - trusting untrusted certificates?" Watch "SSL - client side - trusting untrusted certificates?" New topic
Author

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:





TRUST MANAGER;





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
 
GeeCON Prague 2014
 
subject: SSL - client side - trusting untrusted certificates?