org.bouncycastle.jce.examples

Class PKCS12Example


public class PKCS12Example
extends java.lang.Object

Example of how to set up a certificiate chain and a PKCS 12 store for a private individual - obviously you'll need to generate your own keys, and you may need to add a NetscapeCertType extension or add a key usage extension depending on your application, but you should get the idea! As always this is just an example...

Method Summary

static Certificate
createCert(PublicKey pubKey, PrivateKey caPrivKey, PublicKey caPubKey)
we generate a certificate signed by our CA's intermediate certficate
static Certificate
createIntermediateCert(PublicKey pubKey, PrivateKey caPrivKey, X509Certificate caCert)
we generate an intermediate certificate signed by our CA
static Certificate
createMasterCert(PublicKey pubKey, PrivateKey privKey)
we generate the CA's certificate
static void
main(String[] args)

Method Details

createCert

public static Certificate createCert(PublicKey pubKey,
                                     PrivateKey caPrivKey,
                                     PublicKey caPubKey)
            throws Exception
we generate a certificate signed by our CA's intermediate certficate

createIntermediateCert

public static Certificate createIntermediateCert(PublicKey pubKey,
                                                 PrivateKey caPrivKey,
                                                 X509Certificate caCert)
            throws Exception
we generate an intermediate certificate signed by our CA

createMasterCert

public static Certificate createMasterCert(PublicKey pubKey,
                                           PrivateKey privKey)
            throws Exception
we generate the CA's certificate

main

public static void main(String[] args)
            throws Exception