public SSLSocketFactory buildSSLSocketFactory() throws KeyStoreException {
  SSLContext sslContext=null;
  try {
    KeyManagerFactory keyManagerFactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    keyManagerFactory.init(keyStore,SSL_KEYSTORE_SECRET);
    KeyManager[] keyManagers=keyManagerFactory.getKeyManagers();
    TrustManager[] trustManagers=new TrustManager[]{createTrustManagerFromDefaultJDKTrustStore()};
    sslContext=SSLContext.getInstance("TLS");
    sslContext.init(keyManagers,trustManagers,null);
    SSLContext.setDefault(sslContext);
  }
 catch (  GeneralSecurityException|IOException e) {
    throw new KeyStoreException("Unable to instantiate SSL context",e);
  }
  return sslContext.getSocketFactory();
}

public SSLSocketFactory buildSSLSocketFactory ( ) throws KeyStoreException { SSLContext sslContext = null ; try { KeyManagerFactory keyManagerFactory = KeyManagerFactory . getInstance ( KeyManagerFactory . getDefaultAlgorithm ( ) ) ; keyManagerFactory . init ( keyStore , SSL_KEYSTORE_SECRET ) ; KeyManager [ ] keyManagers = keyManagerFactory . getKeyManagers ( ) ; TrustManager [ ] trustManagers = new TrustManager [ ] { createTrustManagerFromDefaultJDKTrustStore ( ) } ; sslContext = SSLContext . getInstance ( "TLS" ) ; sslContext . init ( keyManagers , trustManagers , null ) ; SSLContext . setDefault ( sslContext ) ; } catch ( GeneralSecurityException | IOException e ) { throw new KeyStoreException ( "Unable to instantiate SSL context" , e ) ; } return sslContext . getSocketFactory ( ) ; }
builds ssl socket factory for http communication
