ge0rg / MemorizingTrustManager

A "plugin" for Android Java to allow asking the user about SSL certificates
MIT License
180 stars 90 forks source link

Use file locking mechanisms for multi-process environments #53

Open rfc2822 opened 8 years ago

rfc2822 commented 8 years ago

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

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 commented 8 years ago

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.