Search in sources :

Example 1 with JcaX509CRLConverter

use of org.bouncycastle.cert.jcajce.JcaX509CRLConverter in project poi by apache.

the class PkiTestUtils method generateCrl.

public static X509CRL generateCrl(X509Certificate issuer, PrivateKey issuerPrivateKey) throws CertificateEncodingException, IOException, CRLException, OperatorCreationException {
    X509CertificateHolder holder = new X509CertificateHolder(issuer.getEncoded());
    X509v2CRLBuilder crlBuilder = new X509v2CRLBuilder(holder.getIssuer(), new Date());
    crlBuilder.setNextUpdate(new Date(new Date().getTime() + 100000));
    JcaContentSignerBuilder contentBuilder = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC");
    CRLNumber crlNumber = new CRLNumber(new BigInteger("1234"));
    crlBuilder.addExtension(Extension.cRLNumber, false, crlNumber);
    X509CRLHolder x509Crl = crlBuilder.build(contentBuilder.build(issuerPrivateKey));
    return new JcaX509CRLConverter().setProvider("BC").getCRL(x509Crl);
}
Also used : JcaX509CRLConverter(org.bouncycastle.cert.jcajce.JcaX509CRLConverter) JcaContentSignerBuilder(org.bouncycastle.operator.jcajce.JcaContentSignerBuilder) CRLNumber(org.bouncycastle.asn1.x509.CRLNumber) X509CertificateHolder(org.bouncycastle.cert.X509CertificateHolder) X509CRLHolder(org.bouncycastle.cert.X509CRLHolder) BigInteger(java.math.BigInteger) X509v2CRLBuilder(org.bouncycastle.cert.X509v2CRLBuilder) Date(java.util.Date)

Aggregations

BigInteger (java.math.BigInteger)1 Date (java.util.Date)1 CRLNumber (org.bouncycastle.asn1.x509.CRLNumber)1 X509CRLHolder (org.bouncycastle.cert.X509CRLHolder)1 X509CertificateHolder (org.bouncycastle.cert.X509CertificateHolder)1 X509v2CRLBuilder (org.bouncycastle.cert.X509v2CRLBuilder)1 JcaX509CRLConverter (org.bouncycastle.cert.jcajce.JcaX509CRLConverter)1 JcaContentSignerBuilder (org.bouncycastle.operator.jcajce.JcaContentSignerBuilder)1