Is Oracle Java KeyStore implementation thread safe?

I am looking to implement a multi-threaded SSL client that uses client certificate authentication, so I need to provide a KeyStore for SSLContext. I need to do this on multiple threads. Can I use a single instance of KeyStore? I will not modify the keystore myself, and I assume that SSL implementation is also not needed, so the object should be effectively immutable.

+6
source share
1 answer

In general, JCA services are not thread safe, and KeyStoreSpi does not impose any thread safety requirements on performers. However, if your keystore is virtually unchanged, and you make sure that its initialized state is visible to all threads, there is no problem. For example, save the KeyStore in a volatile variable or load it from the class initializer (which can be difficult due to exception handling).

+1
source

Source: https://habr.com/ru/post/956666/


All Articles