code: static KeyStore buildKeyStore(X509Certificate[] certChain, PrivateKey key, char[] keyPasswordChars)
              throws KeyStoreException, NoSuchAlgorithmException,
                     CertificateException, IOException {
          KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
          ks.load(null, null);
          ks.setKeyEntry(ALIAS, key, keyPasswordChars, certChain);
          return ks;
      }
docs: Generates a new {@link KeyStore}.
  
  @param certChain a X.509 certificate chain
  @param key a PKCS#8 private key
  @param keyPasswordChars the password of the {@code keyFile}.
  {@code null} if it's not password-protected.
  @return generated {@link KeyStore}.