This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SSL - client side - trusting untrusted certificates?

Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic