JCas
v0.3.1

cas.io
Class ImportKey

java.lang.Object
  extended bycas.io.ImportKey

public class ImportKey
extends Object

Class for importing certificates and keys. This class provides a method for importing a certificate and a private key into a key store. Both the key and the certificate must be in DER-format. The key must be encoded with PKCS#8-format. The certificate must be encoded in X.509-format.

Key format:

openssl pkcs8 -topk8 -nocrypt -in YOUR.KEY -out YOUR.KEY.der -outform der

Format of the certificate:

openssl x509 -in YOUR.CERT -out YOUR.CERT.der -outform der

Import key and certificate:

java comu.ImportKey YOUR.KEY.der YOUR.CERT.der



Constructor Summary
ImportKey()
           
 
Method Summary
static void importKey(KeyStore ks, String keyfile, String certfile, char[] keypass, String alias)
          Imports a certificate and its private key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImportKey

public ImportKey()
Method Detail

importKey

public static void importKey(KeyStore ks,
                             String keyfile,
                             String certfile,
                             char[] keypass,
                             String alias)
                      throws IOException,
                             GeneralSecurityException
Imports a certificate and its private key.

Private key must be in PKCS8-format.

Certificate must be in X.509-format.

If alias is key is imported with the alias importkey

Parameters:
ks - - keystore to use
keyfile - - the private key to import
certfile - - the certificate to import
keypass - - the password of the private key
alias - - Alias for the key.
Throws:
IOException
GeneralSecurityException

JCas
v0.3.1