Merge "Add analytics to track of what cipher suites are being used" into ub-gmail-ur14-dev

This commit is contained in:
Martin Hibdon 2014-10-24 19:34:09 +00:00 committed by Android (Google) Code Review
commit 21dc44d235
2 changed files with 14 additions and 1 deletions

View File

@ -234,10 +234,10 @@ public class SSLSocketFactoryWrapper extends javax.net.ssl.SSLSocketFactory {
ssl.startHandshake();
SSLSession session = ssl.getSession();
LogUtils.d(LogUtils.TAG, "using cipherSuite %s", session.getCipherSuite());
if (session == null) {
throw new SSLException("Cannot verify SSL socket without session");
}
LogUtils.d(LogUtils.TAG, "using cipherSuite %s", session.getCipherSuite());
if (!HttpsURLConnection.getDefaultHostnameVerifier().verify(hostname, session)) {
throw new SSLPeerUnverifiedException("Cannot verify hostname: " + hostname);
}

View File

@ -24,6 +24,7 @@ import com.android.emailcommon.mail.CertificateValidationException;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.utility.SSLUtils;
import com.android.mail.analytics.Analytics;
import com.android.mail.utils.LogUtils;
import java.io.BufferedInputStream;
@ -121,6 +122,13 @@ public class MailTransport {
if (canTrySslSecurity() && !canTrustAllCertificates()) {
verifyHostname(mSocket, getHost());
}
if (mSocket instanceof SSLSocket) {
final SSLSocket sslSocket = (SSLSocket) mSocket;
if (sslSocket.getSession() != null) {
Analytics.getInstance().sendEvent("cipher_suite", "open",
sslSocket.getSession().getCipherSuite(), 0);
}
}
mIn = new BufferedInputStream(mSocket.getInputStream(), 1024);
mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512);
mSocket.setSoTimeout(SOCKET_READ_TIMEOUT);
@ -159,6 +167,11 @@ public class MailTransport {
mIn = new BufferedInputStream(mSocket.getInputStream(), 1024);
mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512);
final SSLSocket sslSocket = (SSLSocket) mSocket;
if (sslSocket.getSession() != null) {
Analytics.getInstance().sendEvent("cipher_suite", "reopenTls",
sslSocket.getSession().getCipherSuite(), 0);
}
} catch (SSLException e) {
if (DebugUtils.DEBUG) {
LogUtils.d(Logging.LOG_TAG, e.toString());