Merge "Introduce an SSL handshake timeout value of 30 seconds." into ub-mail-master

This commit is contained in:
Anthony Lee 2014-02-13 19:15:42 +00:00 committed by Android (Google) Code Review
commit c165d9bd77
1 changed files with 5 additions and 2 deletions

View File

@ -54,6 +54,9 @@ public class SSLUtils {
private static final boolean LOG_ENABLED = false;
private static final String TAG = "Email.Ssl";
// A 30 second SSL handshake should be more than enough.
private static final int SSL_HANDSHAKE_TIMEOUT = 30000;
/**
* A trust manager specific to a particular HostAuth. The first time a server certificate is
* encountered for the HostAuth, its certificate is saved; subsequent checks determine whether
@ -144,7 +147,7 @@ public class SSLUtils {
HostAuth hostAuth, boolean insecure) {
if (insecure) {
SSLCertificateSocketFactory insecureFactory = (SSLCertificateSocketFactory)
SSLCertificateSocketFactory.getInsecure(0, null);
SSLCertificateSocketFactory.getInsecure(SSL_HANDSHAKE_TIMEOUT, null);
insecureFactory.setTrustManagers(
new TrustManager[] {
new SameCertificateCheckingTrustManager(context, hostAuth)});
@ -152,7 +155,7 @@ public class SSLUtils {
} else {
if (sSecureFactory == null) {
sSecureFactory = (SSLCertificateSocketFactory)
SSLCertificateSocketFactory.getDefault(0, null);
SSLCertificateSocketFactory.getDefault(SSL_HANDSHAKE_TIMEOUT, null);
}
return sSecureFactory;
}