KeyStoreUtils.java:

public static void createKeyStore(List<String> certFilesPaths, String keyStorePath, String keyStorePasswd)
    throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {

  KeyStore keyStore = KeyStore.getInstance("JKS");
  keyStore.load(null, null);

  for (String certFile : certFilesPaths) {
    try (FileInputStream certificateStream = new FileInputStream(new File(certFile))) {
      while (certificateStream.available() > 0) {
        Certificate certificate = CertificateFactory.getInstance("X.509").generateCertificate(certificateStream);
        keyStore.setCertificateEntry(certFile, certificate);
      }
    }
  }

  keyStore.store(new FileOutputStream(keyStorePath), keyStorePasswd.toCharArray());
}


Usage

KeyStoreUtils.createKeyStore(
  Lists.newArrayList("<the path to>/cosmos-db-emulator.pem"),
  trustStorePath,
  "changeit"
);

with VM arguments:

javax.net.ssl.trustStore: <the path to>/keyStorePath
javax.net.ssl.trustStorePassword: changeit
javax.net.ssl.trustStoreType: PKCS12


Certificate content

View Website's Public Certificate View Website’s Public Certificate


Save Website's Public PEM Certificate Save Website’s Public PEM Certificate