Using multiple trust stores for https

J

Jon Skeet

Hi folks - long time no post.

I'm back in Java-land at the moment, and trying to sort out an SSL
problem. I need to open an https connection using a specific trust
store, but I *don't* want to use the system property of
javax.net.ssl.trustStore, as this shouldn't be an application-wide
setting. I've been poring over the docs for SSLSocketFactory etc but
I'm blowed if I can see what I should be doing.

Everything I've found using Google seems to refer to setting the system
property, apart from one post from November 2000 asking a similar
question and getting no replies.

Any suggestions?

Jon Skeet
 
A

Arnaud B.

Hi,

Maybe you could search for the apache tomcat implementation :

org.apache.catalina.net.SSLServerSocketFactory

This one seems to have methods to specify KeyStore stuff.

Hope it helps.

Regards,

Arnaud
 
J

Jon Skeet

Arnaud said:
Maybe you could search for the apache tomcat implementation :

org.apache.catalina.net.SSLServerSocketFactory

This one seems to have methods to specify KeyStore stuff.

It's more a case of working where to plug things in. However, I believe
I'm now making progress. I'm using this within the context of Hessian,
and I *think* I've just got to create an SSLContext (which is what I'm
working on now) and then after URL.openConnection has been called, set
the SSLServerSocketFactory on the HttpsURLConnection to be one returned
by the context. I'll have a look at the Tomcat implementation if I run
into trouble though, thanks.

Jon
 
J

Jon Skeet

Jon said:
It's more a case of working where to plug things in. However, I believe
I'm now making progress. I'm using this within the context of Hessian,
and I *think* I've just got to create an SSLContext (which is what I'm
working on now) and then after URL.openConnection has been called, set
the SSLServerSocketFactory on the HttpsURLConnection to be one returned
by the context.

Just to confirm - I've now done this, and it works fine. You can set up
the context once, cache the SSLSocketFactory returned by
getSocketFactory, set that as the socket factory for an
HttpsURLConnection, and everything is fine.

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top