Description: Remove the code disabling the SSL certificate validation
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: not-needed
--- a/src/main/java/com/ning/http/util/SslUtils.java
+++ b/src/main/java/com/ning/http/util/SslUtils.java
@@ -51,11 +51,7 @@
     public static SSLContext getSSLContext()
             throws GeneralSecurityException, IOException {
         SSLConfig config = new SSLConfig();
-        if (config.keyStoreLocation == null || config.trustStoreLocation == null) {
-            return getLooseSSLContext();
-        } else {
-            return getStrictSSLContext(config);
-        }
+        return getStrictSSLContext(config);
     }
 
     static SSLContext getStrictSSLContext(SSLConfig config)
@@ -95,29 +91,6 @@
         return context;
     }
 
-    static SSLContext getLooseSSLContext()
-            throws GeneralSecurityException {
-        SSLContext sslContext = SSLContext.getInstance("TLS");
-        sslContext.init(null, new TrustManager[]{LooseTrustManager.INSTANCE}, new SecureRandom());
-        return sslContext;
-    }
-
-    static class LooseTrustManager
-            implements X509TrustManager {
-
-        public static final LooseTrustManager INSTANCE = new LooseTrustManager();
-
-        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
-            return null;
-        }
-
-        public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
-        }
-
-        public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
-        }
-    }
-
     private final static class SSLConfig {
 
         public String keyStoreLocation;
--- a/src/main/java/com/ning/http/client/providers/apache/ApacheAsyncHttpProvider.java
+++ b/src/main/java/com/ning/http/client/providers/apache/ApacheAsyncHttpProvider.java
@@ -130,24 +130,6 @@
     private final MultiThreadedHttpConnectionManager connectionManager;
     private final HttpClientParams params;
 
-    static {
-        final SocketFactory factory = new TrustingSSLSocketFactory();
-        Protocol.registerProtocol("https", new Protocol("https", new ProtocolSocketFactory() {
-            public Socket createSocket(String string, int i, InetAddress inetAddress, int i1) throws IOException {
-                return factory.createSocket(string, i, inetAddress, i1);
-            }
-
-            public Socket createSocket(String string, int i, InetAddress inetAddress, int i1, HttpConnectionParams httpConnectionParams)
-                    throws IOException {
-                return factory.createSocket(string, i, inetAddress, i1);
-            }
-
-            public Socket createSocket(String string, int i) throws IOException {
-                return factory.createSocket(string, i);
-            }
-        }, 443));
-    }
-
     public ApacheAsyncHttpProvider(AsyncHttpClientConfig config) {
         this.config = config;
         connectionManager = new MultiThreadedHttpConnectionManager();
@@ -732,72 +714,6 @@
         }
     }
 
-    private static class TrustingSSLSocketFactory extends SSLSocketFactory {
-        private SSLSocketFactory delegate;
-
-        private TrustingSSLSocketFactory() {
-            try {
-                SSLContext sslcontext = SSLContext.getInstance("SSL");
-
-                sslcontext.init(null, new TrustManager[]{new TrustEveryoneTrustManager()}, new SecureRandom());
-                delegate = sslcontext.getSocketFactory();
-            } catch (KeyManagementException e) {
-                throw new IllegalStateException();
-            } catch (NoSuchAlgorithmException e) {
-                throw new IllegalStateException();
-            }
-        }
-
-        @Override
-        public Socket createSocket(String s, int i) throws IOException, UnknownHostException {
-            return delegate.createSocket(s, i);
-        }
-
-        @Override
-        public Socket createSocket(String s, int i, InetAddress inetAddress, int i1) throws IOException, UnknownHostException {
-            return delegate.createSocket(s, i, inetAddress, i1);
-        }
-
-        @Override
-        public Socket createSocket(InetAddress inetAddress, int i) throws IOException {
-            return delegate.createSocket(inetAddress, i);
-        }
-
-        @Override
-        public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress1, int i1) throws IOException {
-            return delegate.createSocket(inetAddress, i, inetAddress1, i1);
-        }
-
-        @Override
-        public String[] getDefaultCipherSuites() {
-            return delegate.getDefaultCipherSuites();
-        }
-
-        @Override
-        public String[] getSupportedCipherSuites() {
-            return delegate.getSupportedCipherSuites();
-        }
-
-        @Override
-        public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException {
-            return delegate.createSocket(socket, s, i, b);
-        }
-    }
-
-    private static class TrustEveryoneTrustManager implements X509TrustManager {
-        public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
-            // do nothing
-        }
-
-        public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
-            // do nothing
-        }
-
-        public X509Certificate[] getAcceptedIssuers() {
-            return new X509Certificate[0];
-        }
-    }
-
     private final class ReaperFuture implements Future, Runnable {
         private Future scheduledFuture;
         private ApacheResponseFuture<?> apacheResponseFuture;
