diff options
| author | Marc Blank <mblank@google.com> | 2012-07-31 15:47:49 -0700 |
|---|---|---|
| committer | Marc Blank <mblank@google.com> | 2012-08-01 09:04:44 -0700 |
| commit | 7d5e2a7c08966ffd4a9e8c78f504cc4fd5be4216 (patch) | |
| tree | 1930d82f96f5b2b01b877196a554abf9324980c8 /emailsync | |
| parent | 691d4311a123cd81e2a6e88da94d9487faa930f0 (diff) | |
| download | android_packages_apps_Email-7d5e2a7c08966ffd4a9e8c78f504cc4fd5be4216.tar.gz android_packages_apps_Email-7d5e2a7c08966ffd4a9e8c78f504cc4fd5be4216.tar.bz2 android_packages_apps_Email-7d5e2a7c08966ffd4a9e8c78f504cc4fd5be4216.zip | |
Do "same certificate" checking when using "trust certificates"
* Refactor/simplify Transport/MailTransport
* Add serverCert column to HostAuth table in EmailProvider
* During first connection to server, save the server certificate
in the HostAuth; on subsequent connections, ensure that the
certificate presented has the same public key as the one
stored
* For now, we'll just fail to connect (with a CertificateException)
if there's a mismatch
TODO: Add some UI to handle different certificates
Bug: 6888866
Change-Id: Ia79497e89eaad8d43617b50d3771121b2ed7f687
Diffstat (limited to 'emailsync')
| -rw-r--r-- | emailsync/src/com/android/emailsync/SyncManager.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/emailsync/src/com/android/emailsync/SyncManager.java b/emailsync/src/com/android/emailsync/SyncManager.java index d81abee60..fe6db1fad 100644 --- a/emailsync/src/com/android/emailsync/SyncManager.java +++ b/emailsync/src/com/android/emailsync/SyncManager.java @@ -204,9 +204,9 @@ public abstract class SyncManager extends Service implements Runnable { protected static Thread sServiceThread = null; // Cached unique device id protected static String sDeviceId = null; - // HashMap of ConnectionManagers that all EAS threads can use (by ssl/port pair) - private static HashMap<Integer, EmailClientConnectionManager> sClientConnectionManagers = - new HashMap<Integer, EmailClientConnectionManager>(); + // HashMap of ConnectionManagers that all EAS threads can use (by HostAuth id) + private static HashMap<Long, EmailClientConnectionManager> sClientConnectionManagers = + new HashMap<Long, EmailClientConnectionManager>(); // Count of ClientConnectionManager shutdowns private static volatile int sClientConnectionManagerShutdownCount = 0; @@ -877,11 +877,10 @@ public abstract class SyncManager extends Service implements Runnable { } }; - static public synchronized EmailClientConnectionManager getClientConnectionManager(boolean ssl, - int port) { + static public synchronized EmailClientConnectionManager getClientConnectionManager( + Context context, HostAuth hostAuth) { // We'll use a different connection manager for each ssl/port pair - int key = (ssl ? 0x10000 : 0) + port; - EmailClientConnectionManager mgr = sClientConnectionManagers.get(key); + EmailClientConnectionManager mgr = sClientConnectionManagers.get(hostAuth.mId); if (mgr == null) { // After two tries, kill the process. Most likely, this will happen in the background // The service will restart itself after about 5 seconds @@ -892,9 +891,11 @@ public abstract class SyncManager extends Service implements Runnable { HttpParams params = new BasicHttpParams(); params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 25); params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, sConnPerRoute); - mgr = EmailClientConnectionManager.newInstance(params, ssl, port); + boolean ssl = hostAuth.shouldUseSsl(); + int port = hostAuth.mPort; + mgr = EmailClientConnectionManager.newInstance(context, params, hostAuth); log("Creating connection manager for port " + port + ", ssl: " + ssl); - sClientConnectionManagers.put(key, mgr); + sClientConnectionManagers.put(hostAuth.mId, mgr); } // Null is a valid return result if we get an exception return mgr; |
