Several SSL Connections in one Application

Hi, Im triing to wirte an application that connects to several SSL- servers. When Im writing an application with one connection I set the systemproperties javax.net.ssl.keyStore and password and use the SSLSocketFactory.getDefault().

But now, this doesnt work, heres my testcode:

System.setProperty("javax.net.ssl.keyStore","c:/keystore1");

System.setProperty("javax.net.ssl.keyStorePassword","123456");

System.setProperty("javax.net.ssl.trustStore","c:/keystore1");

System.setProperty("javax.net.ssl.trustStorePassword","123456");

SSLSocket s = (SSLSocket) SSLSocketFactory.getDefault().createSocket("server1", 1099);

s.startHandshake();

System.out.println("Handshake1 works");

System.setProperty("javax.net.ssl.keyStore","c:/keystore2");

System.setProperty("javax.net.ssl.keyStorePassword","tetappl");

System.setProperty("javax.net.ssl.trustStore","c:/keystore2");

System.setProperty("javax.net.ssl.trustStorePassword","tetappl");

s = (SSLSocket) SSLSocketFactory.getDefault().createSocket("server2", 636);

s.startHandshake();

System.out.println("Handshake2 works");

Of cause, if this worked, I didnt write here. I think I have to create one SocketFactory for each connection, but I dont know how. Please help.

Bye Michael

[1854 byte] By [MichaelBullaa] at [2007-10-2 20:41:51]
# 1

SSLContext.getInstance().getSocketFactory(). You'll have to make other arrangements instead of the system properties. See SSLContext.init() and work your way down from there to creating your own trust managers. See also the Javadoc Guide to Features/Security/JSSE for how to create trust managers and keystore managers.

ejpa at 2007-7-13 23:25:10 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2
Thanks a lot, that helped
MichaelBullaa at 2007-7-13 23:25:10 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...