public void createKeyStore(Path filePath, String password)
      throws GeneralSecurityException, IOException {
    KeyStore ks = createEmptyKeyStore();

    for (Map.Entry<String, CertificateMaterial> entry : keyStoreEntries.entrySet()) {
      CertificateMaterial cert = entry.getValue();

      List<Certificate> chain = new ArrayList<>();
      chain.add(cert.getCertificate());

      cert.getIssuer().ifPresent(chain::add);

      ks.setKeyEntry(entry.getKey(), cert.getPrivateKey(), password.toCharArray(),
          chain.toArray(new Certificate[] {}));
    }
    try (OutputStream out = Files.newOutputStream(filePath)) {
      ks.store(out, password.toCharArray());
    }
  }
The {@code CertStores} class encapsulates the key and trust stores typically used by various
components in a Geode cluster. It currently supports certificate collections for servers,
locators and clients. All certificates are signed by a single Root Certificate Authority.
geode-junit/src/main/java/org/apache/geode/cache/ssl/CertStores.java