Retrieving a Certificate from a Key Store
try {
// Load the keystore in the user's home directory
FileInputStream is = new FileInputStream(System.getProperty("user.home")
+ File.separatorChar + ".keystore");
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(is, "my-keystore-password".toCharArray());
// Get certificate
java.security.cert.Certificate cert = keystore.getCertificate("myalias");
} catch (KeyStoreException e) {
} catch (java.security.cert.CertificateException e) {
} catch (NoSuchAlgorithmException e) {
} catch (java.io.IOException e) {
}
Post a comment