createServerSocket second time

I am working on a project which need to reinitialize SSLContext, then

> from SSLContext I do factory = context.getServerSocketFactory(); before

> I reinitialize the SSLContext for the second time, SSLServerSocket was

> closed by invoking sl.close(). (sl is the instance to SSLServerSocket).

>

> now I will need to (SSLServerSocket) factory.createServerSocket(portnum,

> 10, iaddr) for second time (the reason I do this for second time is that

> I have reinitialized SSLContext with

> a different certificate). Before I createServerSocket, for

> ServerSocket, I setReuseAddress(true). Now problem is that

> createServerSocket is hanging, but no exception is thrown. Would you

> please give me

> some advise on how to proceed this further?

[861 byte] By [yixdsa] at [2007-11-27 9:35:47]
# 1
You don't need to reinitialize the SSLContext. You can only do that if you have a KeyManager, and if you have a KeyManager you must also have a KeyStore, so just add the certificate directly into that.
ejpa at 2007-7-12 23:03:22 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2

The two certificates are already in the keystore, when initialized SSLContext with KeyManager which selected first certificate, the ssl connection failed on this certificate, So I need to have keyManager reselect second certificate, then

reinitialize SSLContext, then make second connection attempt. If I don't reinitialize the SSLContext, how do I make sure that SSLContext is now with

second certificate?

Thanks.

yixdsa at 2007-7-12 23:03:22 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 3
Just load the 2nd certificate into the KeyStore. The KeyManager is still using the same KeyStore, and the SSLContext is still using the same KeyManager, so why wouldn't it work?
ejpa at 2007-7-12 23:03:22 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 4

THE TWO CERTIFICATES ARE ALREADY IN THE KeyStore. The Key Manager

always select first certificate in the certificate combo. I created a customized key manager which allow me to select second certificate based on alias. Now

PLEASE remember, the TWO CERTIFICATES ARE ALREADY IN THE KeyStore.

(the 2nd certificate is already in the KeyStore). Now how do I make sure

SSLContext is with 2nd certificate without reinitializing SSLContext with customized key manager ?

Thanks.

yixdsa at 2007-7-12 23:03:22 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 5
anyone knows?
yixdsa at 2007-7-12 23:03:22 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 6
> Now how do I make sure SSLContext is with 2nd certificate without reinitializing SSLContext with customized key manager?Just make your customized key manager externally controllable, and change its behaviour at the appropriate time. The SSLContext will keep using it.
ejpa at 2007-7-12 23:03:22 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...