Introduce an SSL handshake timeout value of 30 seconds.
Motorola 0009-IKXREL1KK-5011 patch. Hanging on an SSL handshake is a real situation that needs to be handled. 30 seconds is more than enough of a timeout to abort on a potential hang. The coincidental thing is that there was a fix that was made a while back to email 1 that addressed the same issue in similar code. You can reference it here: b/7583420. Change-Id: I0533e57f8c5d45d241adb7f37d54ebe1f0ad9368
This commit is contained in:
parent
1e05bc7d73
commit
37a4c65e58
@ -54,6 +54,9 @@ public class SSLUtils {
|
|||||||
private static final boolean LOG_ENABLED = false;
|
private static final boolean LOG_ENABLED = false;
|
||||||
private static final String TAG = "Email.Ssl";
|
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
|
* 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
|
* encountered for the HostAuth, its certificate is saved; subsequent checks determine whether
|
||||||
@ -144,7 +147,7 @@ public class SSLUtils {
|
|||||||
HostAuth hostAuth, boolean insecure) {
|
HostAuth hostAuth, boolean insecure) {
|
||||||
if (insecure) {
|
if (insecure) {
|
||||||
SSLCertificateSocketFactory insecureFactory = (SSLCertificateSocketFactory)
|
SSLCertificateSocketFactory insecureFactory = (SSLCertificateSocketFactory)
|
||||||
SSLCertificateSocketFactory.getInsecure(0, null);
|
SSLCertificateSocketFactory.getInsecure(SSL_HANDSHAKE_TIMEOUT, null);
|
||||||
insecureFactory.setTrustManagers(
|
insecureFactory.setTrustManagers(
|
||||||
new TrustManager[] {
|
new TrustManager[] {
|
||||||
new SameCertificateCheckingTrustManager(context, hostAuth)});
|
new SameCertificateCheckingTrustManager(context, hostAuth)});
|
||||||
@ -152,7 +155,7 @@ public class SSLUtils {
|
|||||||
} else {
|
} else {
|
||||||
if (sSecureFactory == null) {
|
if (sSecureFactory == null) {
|
||||||
sSecureFactory = (SSLCertificateSocketFactory)
|
sSecureFactory = (SSLCertificateSocketFactory)
|
||||||
SSLCertificateSocketFactory.getDefault(0, null);
|
SSLCertificateSocketFactory.getDefault(SSL_HANDSHAKE_TIMEOUT, null);
|
||||||
}
|
}
|
||||||
return sSecureFactory;
|
return sSecureFactory;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user