use of com.android.org.bouncycastle.x509.extension.AuthorityKeyIdentifierStructure in project wso2-synapse by wso2.
the class CRLVerifierTest method createCRL.
/**
* Creates a fake CRL for the fake CA. The fake certificate with the given revokedSerialNumber will be marked
* as Revoked in the returned CRL.
* @param caCert the fake CA certificate.
* @param caPrivateKey private key of the fake CA.
* @param revokedSerialNumber the serial number of the fake peer certificate made to be marked as revoked.
* @return the created fake CRL
* @throws Exception
*/
public static X509CRL createCRL(X509Certificate caCert, PrivateKey caPrivateKey, BigInteger revokedSerialNumber) throws Exception {
X509V2CRLGenerator crlGen = new X509V2CRLGenerator();
Date now = new Date();
crlGen.setIssuerDN(caCert.getSubjectX500Principal());
crlGen.setThisUpdate(now);
crlGen.setNextUpdate(new Date(now.getTime() + TestConstants.NEXT_UPDATE_PERIOD));
crlGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
crlGen.addCRLEntry(revokedSerialNumber, now, CRLReason.privilegeWithdrawn);
crlGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(caCert));
crlGen.addExtension(X509Extensions.CRLNumber, false, new CRLNumber(BigInteger.valueOf(1)));
return crlGen.generateX509CRL(caPrivateKey, "BC");
}
Aggregations