简体   繁体   English

Java SSL Truststore设置

[英]Java SSL Truststore settings

In one application i'm using three different connections by SSL. 在一个应用程序中,我通过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. 但是,这将导致争用情况:如果在设置了此信任库的同时另一个线程建立了SSL连接,它将也使用此信任库而不是标准的信任库。

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. 但是,这是否容易(甚至可能)取决于建立SSL连接的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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