use of org.bouncycastle.cert.X509CRLHolder in project jruby-openssl by jruby.
the class X509CRL method getSignatureAlgorithm.
private String getSignatureAlgorithm(final Ruby runtime, final String def) {
final X509CRLHolder crlHolder = getCRLHolder(true);
if (crlHolder == null)
return def;
ASN1ObjectIdentifier algId = crlHolder.toASN1Structure().getSignatureAlgorithm().getAlgorithm();
// ASN1ObjectIdentifier algId = ASN1.toObjectID( getCRL().getSigAlgOID(), true );
String algName;
if (algId != null) {
algName = ASN1.o2a(runtime, algId, true);
} else
algName = null;
// }
return algName == null ? def : algName;
}
use of org.bouncycastle.cert.X509CRLHolder 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 {
JcaX509ExtensionUtils extUtils = new JcaX509ExtensionUtils();
Date now = new Date();
X500Name issuer = X500Name.getInstance(PrincipalUtil.getIssuerX509Principal(caCert).getEncoded());
X509v2CRLBuilder builder = new X509v2CRLBuilder(issuer, new Date());
builder.addCRLEntry(revokedSerialNumber, new Date(), 0);
builder.setNextUpdate(new Date(now.getTime() + TestConstants.NEXT_UPDATE_PERIOD));
builder.addExtension(Extension.cRLDistributionPoints, false, extUtils.createAuthorityKeyIdentifier(caCert));
builder.addExtension(Extension.cRLNumber, false, new CRLNumber(BigInteger.valueOf(1)));
JcaContentSignerBuilder contentSignerBuilder = new JcaContentSignerBuilder("SHA256WithRSAEncryption");
contentSignerBuilder.setProvider(CryptoConstants.BOUNCY_CASTLE_PROVIDER);
X509CRLHolder cRLHolder = builder.build(contentSignerBuilder.build(caPrivateKey));
JcaX509CRLConverter converter = new JcaX509CRLConverter();
converter.setProvider(CryptoConstants.BOUNCY_CASTLE_PROVIDER);
return converter.getCRL(cRLHolder);
}
Aggregations