The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.security  [30 examples] > Key Store  [4 examples]

e209. 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) {
    }

 Related Examples
e208. Listing the Aliases in a Key Store
e210. Retrieving a Key Pair from a Key Store
e211. Adding a Certificate to a Key Store

See also: Message Digests    Permissions    Policy Files    Public and Private Keys    Signatures   


© 2002 Addison-Wesley.