Code example for HttpsURLConnection

Methods: setHostnameVerifier, setSSLSocketFactory

            // Install hostname verifiers and trust managers that don't do 
            // anything in order to get around the client not trusting 
            // the test server due to a lack of certificates. 
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setHostnameVerifier(new TestHostnameVerifier());
            SSLContext context = SSLContext.getInstance("TLS");
            TestTrustManager trustManager = new TestTrustManager();
            context.init(null, new TestTrustManager[] {trustManager}, null);
            return connection;
        } else { 
            return url.openConnection();
     * {@link X509TrustManager} that trusts everybody. This is used so that 
     * the client calling {@link TestWebServer#shutdown()} can issue a request