public static void addSSLProperties(Properties props, String sslEnabledDatacenters, SSLFactory.Mode mode,
      File trustStoreFile, String certAlias, String sslContextProvider) throws IOException, GeneralSecurityException {
    Map<String, X509Certificate> certs = new HashMap<>();
    File keyStoreFile;
    String password;

    if (mode == SSLFactory.Mode.CLIENT) {
      password = "UnitTestClientKeyStorePassword";
      keyStoreFile = File.createTempFile("selfsigned-keystore-client", ".jks");
      KeyPair cKP = generateKeyPair("RSA");
      X509Certificate cCert = generateCertificate("CN=localhost, O=client", cKP, 30, "SHA1withRSA",
          Optional.empty());
      createKeyStore(keyStoreFile.getPath(), password, password, certAlias, cKP.getPrivate(), cCert);
      certs.put(certAlias, cCert);
    } else {
      password = "UnitTestServerKeyStorePassword";
      keyStoreFile = File.createTempFile("selfsigned-keystore-server", ".jks");
      KeyPair sKP = generateKeyPair("RSA");
      X509Certificate sCert = generateCertificate("CN=localhost, O=server", sKP, 30, "SHA1withRSA",
          Optional.empty());
      createKeyStore(keyStoreFile.getPath(), password, password, certAlias, sKP.getPrivate(), sCert);
      certs.put(certAlias, sCert);
    }

    createTrustStore(trustStoreFile.getPath(), TRUSTSTORE_PASSWORD, certs);

    props.put("ssl.context.protocol", SSL_CONTEXT_PROTOCOL);
    props.put("ssl.context.provider", sslContextProvider == null ? SSL_CONTEXT_PROVIDER : sslContextProvider);
    props.put("ssl.enabled.protocols", TLS_V1_2_PROTOCOL);
    props.put("ssl.endpoint.identification.algorithm", ENDPOINT_IDENTIFICATION_ALGORITHM);
    props.put("ssl.client.authentication", CLIENT_AUTHENTICATION);
    props.put("ssl.keymanager.algorithm", KEYMANAGER_ALGORITHM);
    props.put("ssl.trustmanager.algorithm", TRUSTMANAGER_ALGORITHM);
    props.put("ssl.keystore.type", KEYSTORE_TYPE);
    props.put("ssl.keystore.path", keyStoreFile.getPath());
    props.put("ssl.keystore.password", password);
    props.put("ssl.key.password", password);
    props.put("ssl.truststore.type", TRUSTSTORE_TYPE);
    props.put("ssl.truststore.path", trustStoreFile.getPath());
    props.put("ssl.truststore.password", TRUSTSTORE_PASSWORD);
    props.put("ssl.cipher.suites", SSL_CIPHER_SUITES);
    props.put("clustermap.ssl.enabled.datacenters", sslEnabledDatacenters);
  }
Generate a cert and add SSL related properties to {@code props}
@param props the {@link Properties} instance.
@param sslEnabledDatacenters a comma separated list of datacenters where SSL should be enabled.
@param mode whether to generate the "client" or "server" certificate.
@param trustStoreFile the file path at which to create the trust store.
@param certAlias the cert alias to use.
@param sslContextProvider the name of a registered security provider to use for instantiating {@link SSLContext}.
@throws IOException
@throws GeneralSecurityException
ambry-test-utils/src/main/java/com/github/ambry/commons/TestSSLUtils.java