MemorizingTrustManager
MemorizingTrustManager copied to clipboard
Don't show multiple decision dialogs for same certificate
At the moment, when several threads (for instance, synchronization workers called by Android) with MTM simultaneously access a host with unknown certificate, multiple decision activities will pop up, so the user will have to do the same decision multiple times. This makes it look like the application is not working correctly.
If there's already a pending decision for a given certificate, this decision should be waited for/used instead of creating a new one.
That's an awesome idea. I've encountered that problem myself in yaxim, where the connection times out after some inactivity and a new one is opened.
I estimate that this needs a change of the openDecisions array into a map that is indexed with the server's hostname. However, the TrustManager API does not expose host names, so we'd need to supply it as a constructor parameter (or have some MTM factory that is passed the hostname).
Initially I planned such an API change for the HostnameVerifier implementation, but did it another way in the end.
Any update on this?