org.bouncycastle.jce.examples
Class PKCS12Example

java.lang.Object
  extended by org.bouncycastle.jce.examples.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...


Field Summary
(package private) static char[] passwd
           
(package private) static X509V1CertificateGenerator v1CertGen
           
(package private) static X509V3CertificateGenerator v3CertGen
           
 
Constructor Summary
PKCS12Example()
           
 
Method Summary
static java.security.cert.Certificate createCert(java.security.PublicKey pubKey, java.security.PrivateKey caPrivKey, java.security.PublicKey caPubKey)
          we generate a certificate signed by our CA's intermediate certficate
static java.security.cert.Certificate createIntermediateCert(java.security.PublicKey pubKey, java.security.PrivateKey caPrivKey, java.security.cert.X509Certificate caCert)
          we generate an intermediate certificate signed by our CA
static java.security.cert.Certificate createMasterCert(java.security.PublicKey pubKey, java.security.PrivateKey privKey)
          we generate the CA's certificate
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

passwd

static char[] passwd

v1CertGen

static X509V1CertificateGenerator v1CertGen

v3CertGen

static X509V3CertificateGenerator v3CertGen
Constructor Detail

PKCS12Example

public PKCS12Example()
Method Detail

createMasterCert

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

Throws:
java.lang.Exception

createIntermediateCert

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

Throws:
java.lang.Exception

createCert

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

Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception