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

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.