Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Adella Garcia   on Jan 31 In Java Category.

  
Question Answered By: Abana Cohen   on Jan 31

You obviously are connecting to a server, whose ssl
certificate does not lead to a root in the default
trust collection delivered with the JRE.

To persuade the ssl  connection with another
certificate or a set of them first you should provide
your own trust manager; aka an implementation of

javax.net.ssl.X509TrustManager

Let's say it is called MyTrustManager. There you put
all your own customized business logic to check and
control ssl certificates.

Then before your acquiring the ssl factory you forge
that trust manager to ssl context using


SSLContext sslContext =
SLContext.getInstance("SSLv3");
MyTrustManager tm = new MyTrustManager(...[whatever
param makes sense to you e.g. set of certificates you
will accept or a file including them]),
TrustManager tms[] = {tm};
sslContext.init(null, tms, null);
SocketFactory socketFactory =
sslContxt.getSocketFactory();

And then you go ahead establishing a connection  to
servers as you entitled before.

Share: 

 
 
Didn't find what you were looking for? Find more on SSL client connection Or get search suggestion and latest updates.


Tagged: