Code example for HttpsURLConnection

Methods: connect, disconnect, setHostnameVerifier, setSSLSocketFactory

0
					} }, null); 
		} catch (KeyManagementException e) { 
			sslCertError = String.format("Unable to set up key management: %s", e.toString()); 
			return; 
		} 
		sslconn.setSSLSocketFactory(context.getSocketFactory()); 
 
		/* 
		 * We must also turn off hostname verification so we don't get an exception 
		 * when connecting. 
		 */ 
		sslconn.setHostnameVerifier(new HostnameVerifier() { 
			public boolean verify(String hostname, SSLSession session) {
				return true; 
			} 
		}); 
 
		try { 
			sslconn.connect(); /* This should trigger our callback */ 
			sslconn.disconnect(); 
		} 
		catch (IOException e) {
			sslCertError = String.format("Unable to connect to server: %s", e.toString());
		} 
	}