code: public SSLEngine initSslEngine(boolean client) throws Exception {
      // Load the keystore
      KeyStore keyStore = loadKeystore(properties.sslKeyStorePath(), properties.sslKeyStorePassword());
  
      // Setup the keyManager to use our keystore
      KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
      keyManagerFactory.init(keyStore, keyStoreKeyPass(properties));
  
      // Setup the Trust keystore
      KeyStore trustStore;
      if (properties.sslTrustStorePath() != null) {
        // Use the separate Trust keystore
        LOGGER.debug("Using separate trust store");
        trustStore = loadKeystore(properties.sslTrustStorePath(), properties.sslTrustStorePassword());
      } else {
        // Reuse the existing keystore
        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;
    }
docs: Initializes an SSL engine.
  
  @param client Indicates whether the engine is being initialized for a client.
  @return The initialized SSL engine.