nl.surfnet.spring.security.opensaml.util
Class KeyStoreUtil

java.lang.Object
  extended by nl.surfnet.spring.security.opensaml.util.KeyStoreUtil

public class KeyStoreUtil
extends Object


Constructor Summary
KeyStoreUtil()
           
 
Method Summary
static void appendCertificateToKeyStore(KeyStore keyStore, String keyAlias, String pemCert)
          Append a certificate to the given key store
static void appendKeyToKeyStore(KeyStore keyStore, String keyAlias, InputStream certificateInputStream, InputStream privatekeyInputStream, char[] password)
          Append a certificate and private key to a keystore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyStoreUtil

public KeyStoreUtil()
Method Detail

appendKeyToKeyStore

public static void appendKeyToKeyStore(KeyStore keyStore,
                                       String keyAlias,
                                       InputStream certificateInputStream,
                                       InputStream privatekeyInputStream,
                                       char[] password)
                                throws IOException
Append a certificate and private key to a keystore.

Parameters:
keyStore - where to append the certificate and private key to
keyAlias - the alias of the key
certificateInputStream - the inputStream containing the certificate in the PEM format
privatekeyInputStream - the input stream containing the private key in the DER format
password - the password on the key

Generate your private key: openssl genrsa -out something.key 1024

Show the PEM private key: openssl asn1parse -inform pem -dump -i -in something.key

Translate the key to pkcs8 DER format: openssl pkcs8 -topk8 -inform PEM -outform DER -in something.key -nocrypt > something.pkcs8.der

Show the DER private key: openssl asn1parse -inform der -dump -i -in something.pkcs8.der

Generate a certificate request: openssl req -new -key something.key -out something.csr

Generate a certificate: openssl x509 -req -days 365 -in something.csr -signkey something.key -out something.crt

Throws:
IOException

appendCertificateToKeyStore

public static void appendCertificateToKeyStore(KeyStore keyStore,
                                               String keyAlias,
                                               String pemCert)
Append a certificate to the given key store

Parameters:
keyStore -
keyAlias -
pemCert -


Copyright © 2012 SURFnet bv, The Netherlands. All Rights Reserved.