Example usage for org.bouncycastle.asn1.cms IssuerAndSerialNumber getEncoded

List of usage examples for org.bouncycastle.asn1.cms IssuerAndSerialNumber getEncoded

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.cms IssuerAndSerialNumber getEncoded.

Prototype

public byte[] getEncoded() throws IOException 

Source Link

Document

Return the default BER or DER encoding for this object.

Usage

From source file:org.ejbca.extra.ra.ScepRequestGenerator.java

License:Open Source License

/** Generates a SCEP CrlReq. Keys must have been set in the generator for this to succeed 
 * /*from  w  w w.  j a v a  2 s . c om*/
 */
public byte[] generateCrlReq(String dn, X509Certificate ca)
        throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException, SignatureException,
        IOException, CMSException, InvalidAlgorithmParameterException, CertStoreException,
        CertificateEncodingException, IllegalStateException {
    this.cacert = ca;
    this.reqdn = dn;
    X509Name name = CertTools.stringToBcX509Name(cacert.getIssuerDN().getName());
    IssuerAndSerialNumber ias = new IssuerAndSerialNumber(name, cacert.getSerialNumber());
    // Create self signed cert, validity 1 day
    cert = CertTools.genSelfCert(reqdn, 24 * 60 * 60 * 1000, null, keys.getPrivate(), keys.getPublic(),
            AlgorithmConstants.SIGALG_SHA1_WITH_RSA, false);

    // wrap message in pkcs#7
    byte[] msg = wrap(ias.getEncoded(), "22");
    return msg;
}