@Override
  public SSLEngine createSSLEngine(String peerHost, int peerPort, Mode mode) {
    SSLEngine sslEngine = sslContext.createSSLEngine(peerHost, peerPort);
    if (cipherSuites != null) {
      sslEngine.setEnabledCipherSuites(cipherSuites);
    }
    if (enabledProtocols != null) {
      sslEngine.setEnabledProtocols(enabledProtocols);
    }

    if (mode == Mode.SERVER) {
      sslEngine.setUseClientMode(false);
      switch (clientAuth) {
        case REQUIRED:
          sslEngine.setNeedClientAuth(true);
          break;
        case REQUESTED:
          sslEngine.setWantClientAuth(true);
          break;
      }
    } else {
      sslEngine.setUseClientMode(true);
      SSLParameters sslParams = sslEngine.getSSLParameters();
      sslParams.setEndpointIdentificationAlgorithm(endpointIdentification);
      sslEngine.setSSLParameters(sslParams);
    }
    return sslEngine;
  }
Create {@link SSLEngine} for given host name and port number.
This engine manages the handshake process and encryption/decryption with this remote host.
@param peerHost The remote host name
@param peerPort The remote port number
@param mode The local SSL mode, Client or Server
@return SSLEngine
ambry-commons/src/main/java/com/github/ambry/commons/JdkSslFactory.java