MemorizingTrustManager icon indicating copy to clipboard operation
MemorizingTrustManager copied to clipboard

Use file locking mechanisms for multi-process environments

Open rfc2822 opened this issue 8 years ago • 1 comments

There might be environments where the key store file might be shared either

  • by multiple MTMs in multiple processes, and/or
  • by MTM and other libraries.

In both cases, thread synchronization within MTM is not enough. So I suggest to use file locking (if available on the platform and for the key store location) to prevent concurrent file access: a shared lock for reading and an exclusive lock for writing.

rfc2822 avatar Jul 12 '16 17:07 rfc2822

Maybe there should also be a mechanism to notify MTMs in other processes when the key store has changed (so that keyStoreUpdated() can be called).

Alternatively, the key store could be loaded for every request. (Maybe as an option, so that only multi-process enviroments have to do that.) However, I don't know the real performance implications. Maybe we should have a look how other multi-threaded or multi-process applications use the KeyStore.

rfc2822 avatar Jul 14 '16 16:07 rfc2822