public SSLEngine initSslEngine(boolean client) throws Exception {
  KeyStore keyStore=loadKeystore(properties.sslKeyStorePath(),properties.sslKeyStorePassword());
  KeyManagerFactory keyManagerFactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
  keyManagerFactory.init(keyStore,keyStoreKeyPass(properties));
  KeyStore trustStore;
  if (properties.sslTrustStorePath() != null) {
    LOGGER.debug("Using separate trust store");
    trustStore=loadKeystore(properties.sslTrustStorePath(),properties.sslTrustStorePassword());
  }
 else {
    trustStore=keyStore;
    LOGGER.debug("Using key store as trust store");
  }
  TrustManagerFactory trustManagerFactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
  trustManagerFactory.init(trustStore);
  KeyManager[] keyManagers=keyManagerFactory.getKeyManagers();
  TrustManager[] trustManagers=trustManagerFactory.getTrustManagers();
  SSLContext sslContext=SSLContext.getInstance("TLS");
  sslContext.init(keyManagers,trustManagers,null);
  SSLEngine sslEngine=sslContext.createSSLEngine();
  sslEngine.setUseClientMode(client);
  sslEngine.setWantClientAuth(true);
  sslEngine.setEnabledProtocols(sslEngine.getSupportedProtocols());
  sslEngine.setEnabledCipherSuites(sslEngine.getSupportedCipherSuites());
  sslEngine.setEnableSessionCreation(true);
  return sslEngine;
}

public SSLEngine initSslEngine ( boolean client ) throws Exception { KeyStore keyStore = loadKeystore ( properties . sslKeyStorePath ( ) , properties . sslKeyStorePassword ( ) ) ; KeyManagerFactory keyManagerFactory = KeyManagerFactory . getInstance ( KeyManagerFactory . getDefaultAlgorithm ( ) ) ; keyManagerFactory . init ( keyStore , keyStoreKeyPass ( properties ) ) ; KeyStore trustStore ; if ( properties . sslTrustStorePath ( ) != null ) { LOGGER . debug ( "Using separate trust store" ) ; trustStore = loadKeystore ( properties . sslTrustStorePath ( ) , properties . sslTrustStorePassword ( ) ) ; } else { trustStore = keyStore ; LOGGER . debug ( "Using key store as trust store" ) ; } TrustManagerFactory trustManagerFactory = TrustManagerFactory . getInstance ( TrustManagerFactory . getDefaultAlgorithm ( ) ) ; trustManagerFactory . init ( trustStore ) ; KeyManager [ ] keyManagers = keyManagerFactory . getKeyManagers ( ) ; TrustManager [ ] trustManagers = trustManagerFactory . getTrustManagers ( ) ; SSLContext sslContext = SSLContext . getInstance ( "TLS" ) ; sslContext . init ( keyManagers , trustManagers , null ) ; SSLEngine sslEngine = sslContext . createSSLEngine ( ) ; sslEngine . setUseClientMode ( client ) ; sslEngine . setWantClientAuth ( true ) ; sslEngine . setEnabledProtocols ( sslEngine . getSupportedProtocols ( ) ) ; sslEngine . setEnabledCipherSuites ( sslEngine . getSupportedCipherSuites ( ) ) ; sslEngine . setEnableSessionCreation ( true ) ; return sslEngine ; }
initializes an ssl engine .
