I have a X509Certificate, derived from CMSSignedData(PKCS7). My question is how can I get the URL to the CRL file to check whether the certificate was revocated. I've tried the code below:
X509CertificateHolder signerCertificateHolder = (X509CertificateHolder) certIt.next();
X509Certificate certificate = new JcaX509CertificateConverter().setProvider("BC").getCertificate(signerCertificateHolder);
X509CRLEntry revokedCertificate;
X509CRL crl;
URL url = new URL("???");
URLConnection connection = url.openConnection();
try(DataInputStream inStream = new DataInputStream(connection.getInputStream()))
{
crl = (X509CRL) cf.generateCRL(inStream);
}
revokedCertificate = crl.getRevokedCertificate(certificate.getSerialNumber());
if(revokedCertificate != null)
{
System.out.println("Revoked");
}
else
{
System.out.println("Valid");
}
And it would work so well, except I cannot get URL to the CRL. I know that it has OI(Object Identifier) - 2.5.29.31. But unfortunatetly I cannot derive it from certificate. How can I do that?