简体   繁体   中英

Java SSL Truststore settings

In one application i'm using three different connections by SSL. Two of them have signed certificates, but one I'm authenticating with:

System.setProperty("javax.net.ssl.trustStore","F:\\eclipse\\terefere\\testkeystore");
System.setProperty("javax.net.ssl.trustStorePassword","123456"); 

Question is - how to get rid of these settings at the end of connection so that next connection is using new server's certificate ?

You could of course remember the old values of these properties and re-set them after this call.

This would introduce a race condition though: if another thread makes an SSL connection while this trust store has been set, it will also use this trust store instead of the standard one.

Better would be to use this trust store for specifically this connection without touching the system properties. Whether this is easy (or even possible) depends on what library is making the SSL connection, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM