From 4d3f3f3ab95c03d4c1ab308801b92ba1d9df2276 Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Wed, 12 Oct 2011 13:41:59 -0700 Subject: [PATCH] Fix hostname verifier for Exchange connections. When the socketfactory init code was moved, I forgot to re-add in the check to skip hostname verification. This made "Trust all SSL certificates" checkbox useless. Bug: 5450563 Change-Id: Ie4cba749aaf8c0fd9f9c43f09ebf354c6600d4f0 --- .../src/com/android/emailcommon/utility/SSLUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/emailcommon/src/com/android/emailcommon/utility/SSLUtils.java b/emailcommon/src/com/android/emailcommon/utility/SSLUtils.java index aa5229aec..b21c68f33 100644 --- a/emailcommon/src/com/android/emailcommon/utility/SSLUtils.java +++ b/emailcommon/src/com/android/emailcommon/utility/SSLUtils.java @@ -74,7 +74,11 @@ public class SSLUtils { if (keyManager != null) { underlying.setKeyManagers(new KeyManager[] { keyManager }); } - return new SSLSocketFactory(underlying); + SSLSocketFactory wrapped = new SSLSocketFactory(underlying); + if (insecure) { + wrapped.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + } + return wrapped; } /**