Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug2229930-crlCertValid-leaf-only #4554

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

ladycfu
Copy link
Contributor

@ladycfu ladycfu commented Aug 25, 2023

This patch addresses the issue where OCSPEngine:crlCertValid attempts to verify up the chain and failed because when using CRL to validate certs, the CAs up the chain are issued by different CAs.
OCSPEngine:crlCertValid should be limited to leaf certs validation only.

fixes https://bugzilla.redhat.com/show_bug.cgi?id=2229930

This patch addresses the issue where OCSPEngine:crlCertValid attempts to
verify up the chain and failed because when using CRL to validate certs,
the CAs up the chain are issued by different CAs.
OCSPEngine:crlCertValid should be limited to leaf certs validation only.

fixes https://bugzilla.redhat.com/show_bug.cgi?id=2229930
Copy link
Contributor

@edewata edewata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too familiar with this area so I have some questions below.

Will this change the responses described in this page?
https://github.com/dogtagpki/pki/wiki/OCSP-status-responses

If it has been sufficiently tested feel free to merge.

if (ext == null)
return false;
else {
Boolean bool = (Boolean) ext.get(BasicConstraintsExtension.IS_CA);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can bool be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question. Boolean by default is null, however, BasicConstraintsExtension has the following defined: // Private data members
private boolean ca = false;

Comment on lines +154 to +155
if (CertUtils.isCACert(cert))
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there ever be a case where the leaf cert is also a CA cert? If that's the case, the leaf cert will not be checked.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it also guaranteed that all non-leaf certs are CA certs? If that's not guaranteed, the loop might pick the wrong cert to check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we just want to check the leaf cert without touching the non-leaf certs at all, we probably can do something like this:

try {
    CertificateChain certChain = new CertificateChain(certificates);
    certChain.sort();
    certificates = certChain.getChain();

    X509Certificate leafCert = certificates[certificates.length - 1];
    return !crlCertValid(crlStore, leafCert, null);

} catch (Exception e) {
    throw new RuntimeException("Unable to check cert revocation: " + e.getMessage(), e);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, I didn't realize there were comments before I clicked merge, so I'm replying after the fact. sorry about it. So, to answer your questions. The crl cert validation is only for validating peer certs. 1. in the pki setup, we never use a ca or self-signed cert for SSL connections, either a client cert, or a server cert. 2. yes all non-leaf certs are supposed to be ca certs, hence forming a chain. 3. Yes your proposal of using CertificateChain to sort is a very good idea. I actually copied a part of this code from JssSubsystem isCACert(). How about we create a separate ticket to combine the two isCACert() and make the improvement at the same time? I'll leave it as it for now, since Pritam has already tested it. Thanks!

@ladycfu ladycfu merged commit 4c2ec42 into dogtagpki:v10.13 Aug 25, 2023
58 checks passed
@ladycfu
Copy link
Contributor Author

ladycfu commented Aug 25, 2023

I'm not too familiar with this area so I have some questions below.

Will this change the responses described in this page? https://github.com/dogtagpki/pki/wiki/OCSP-status-responses

If it has been sufficiently tested feel free to merge.

No. This fix should not affect the outcome. My understanding is that this area is for using CRL to verify ocsp's peer certs, not for responding to ocsp requests. @fmarco76 please confirm. Thanks!

@fmarco76
Copy link
Member

Yes, I have not tested this code but it is not related to the OCSP output, only to the internal verification so the status table is still valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants