I have a CRL and a self-signed certificate that acts as a CA Certificate. I need to verify that the same CA has issued both the CRL and the root certificate in Java. The way I thought of was this:
X500Principal rootCertIssuer = rootCertificate.getIssuerX500Principal();
X500Principal crlIssuer = crl.getIssuerX500Principal();
if(rootCertIssuer.getName().equals(crlIssuer.getName()))
System.out.println("Issuer same!");
else
System.out.println("Issuer different!");
This does not seem right, because in case Country/State information is missing in one of either the CRL or the root certificate, equals()
will return a false
. How do I proceed? Or, opposed to what I think, is this approach right?
Thank you!
As it was mentioned by @frasertweedale, certificate issuer and CRL issuer not necessarily need to be the same. Though, there is no much reason to delegate CRL issuance to another authority and not all systems support that. For example, Windows chain validation code only supports CRLs issued by (signed by) the same CA that issued the cert covered by the CRL.
In general, validation logic consist of two parts and looks like this:
CRLDistributionPoints
sequence. If there is an entry with presentedcRLIssuer
structure, then CRL referenced by this distribution point is signed by an entity specified in thecRLIssuer
field. IfcRLIssuer
field is not presented, then certificate and CRL are signed by the same CA and CRL location is specified in thedistributionPointName
field.CRL validation against issuer is performed in two steps:
Issuer
filed in CRL andSubject
field of CRL issuer certificate. If comparison fails, CRL is invalid.more information about CRL Distribution Points extension composition and processing rules: RFC 5280 ยง4.2.1.13