Is it possible to change encryption keystore more than once?

It seems that once my environment has been informed of a keystore to use for ssl communication, it can't be changed. Is this so?

I need to be able to do the following:

1) Set a keystore for ssl communicaton

2) Establish an ssl connection, (send and receive stuff), and end the connection.

3) CHANGE THE KEYSTORE TO SOME OTHER THAN THAT USED IN STEP ONE.

4) Repeat. step 2.

However, step 3 seems to fail. The properties are set, but in step 4 the server STILL reports that the client is using the PREVIOUS key for encryption.

Is there a way to FORCE it to change?

Thank you in advance for your consideration.

Here's some of the code:

======================================================

Methods for beginning and ending session:

--

public String start_session(File client_hashcode_file)

throws Exception

{

try{

sslsocketfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();

m_ssl_socket=(SSLSocket)sslsocketfactory.createSocket(m_server_host, m_server_port);

m_ssl_socket.startHandshake(); //Added this to see if it would force the change

m_socket_writer = new BufferedWriter(new OutputStreamWriter(m_ssl_socket.getOutputStream()));

m_socket_reader = new BufferedReader(newInputStreamReader(m_ssl_socket.getInputStream()));

}

catch (Exception e){

throw new Exception("Server connection failed: [" + e.getMessage() + "]");

}

// Process, process, process......

}

public void

end_session()

throws java.io.IOException

{

m_ssl_socket.getSession().getSessionContext().setSessionTimeout(1);

m_ssl_socket.getSession().invalidate();

m_ssl_socket.close();

}

=========================================================

Method to set/REset keystore:

-

public void newCert(String keystorePath, char[] passwd)

throws KeyStoreAccessException

{

// Set some stuff...

// Set the system properties required to use this certificate for

// client authentication.

the_properties.setProperty("javax.net.ssl.keyStore", keystorePath);

the_properties.setProperty("javax.net.ssl.keyStoreType", "PKCS12");

the_properties.setProperty("javax.net.ssl.keyStorePassword", password);

// Set some other stuff...

}

[2393 byte] By [midgeta] at [2007-10-2 9:53:49]
# 1
Not via system properties. You could code something up using your own TrustStoreManager.
ejpa at 2007-7-16 23:58:40 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...