Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Not getting callbacks for X509TrustManager

809707Nov 1 2010 — edited Nov 3 2010
hi,

We have an applet trying to connect to server over SSL. Its socket communication. Here i m trying to make the applet open SSL conneciton with server.

the applet is trying to connect to the server over a Fully qualified domain name whose ip is resolved via hosts file. I gave implementation of the X509TrustManager and added it to SSLContext. HOw ever i dont see any call back during the SSL hand shake. I verified this using debug point in eclipse.

-----------------------------

the code is as follows
static {
try {
TrustManager[] setupTrustManager=new TrustManager[]{new *DevTrustManager*()};
SSLContext sslContext = SSLContext.getInstance("TLSv1");
KeyStore emptyKeyStore = KeyStore.getInstance("JKS");
emptyKeyStore.load(null);
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509", "SunJSSE");
keyManagerFactory.init(emptyKeyStore,null);
sslContext.init(keyManagerFactory.getKeyManagers(), setupTrustManager, new java.security.SecureRandom());
factory = sslContext.getSocketFactory();
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] argv){
SSLSocket socket = connectSocket("connservice123.company.co.in", 2147, 0);
if(socket!=null){
System.out.println("conn established...\n" + socket.isConnected());
}
}

--------------
DevTrustManager

DevTrustManager implements X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
System.out.println("33333333333");
return null;
}

public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
System.out.println("1111111111111");
}

public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
System.out.println("222222222222");
}
} };

-------------

When i run the above i get the below SOP:
conn established...
true

Any ideas why the DevTrustManager methods are not getting the callback. The class is a dummy implementation of X509TrustManager with SOPS in it.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2010
Added on Nov 1 2010
4 comments
643 views