Code example for SSLSocketFactory

Methods: setHostnameVerifier

1
			Context context) {
		try { 
			// Pass the keystore to the SSLSocketFactory. The factory is 
			// responsible 
			// for the verification of the server certificate. 
			SSLSocketFactory sf = new SSLSocketFactory(loadOWKeyStore(context));
			// Hostname verification from certificate 
			// http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e506 
			sf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
			return sf;
		} catch (Exception e) {
			throw new AssertionError(e);
		} 
	} 
 
 
	private static KeyStore loadOWKeyStore(Context c) {
		KeyStore trusted = null;
		try { 
			// Get an instance of the Bouncy Castle KeyStore format 
			trusted = KeyStore.getInstance("BKS");