Skip to content

Instantly share code, notes, and snippets.

@icarocamelo
Created September 24, 2015 19:53
Show Gist options
  • Save icarocamelo/23570ca9a6360b98ba70 to your computer and use it in GitHub Desktop.
Save icarocamelo/23570ca9a6360b98ba70 to your computer and use it in GitHub Desktop.
add-to-keystore
public java.security.cert.Certificate getCert(Certificate certificate,
InputStream certificateStream) throws NoSuchAlgorithmException,
CertificateException, IOException, KeyStoreException {
String alias = "alias"; // TODO: replace for certificate.getAlias()
KeyStore keystore = KeyStore.getInstance("JKS");
keystore.load(certificateStream,
certificate.getKeyPassword().toCharArray());
java.security.cert.Certificate cert = keystore.getCertificate(alias);
return cert;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment