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

Fix ocsp unknown ca #4542

Merged
merged 9 commits into from
Aug 16, 2023
Merged

Fix ocsp unknown ca #4542

merged 9 commits into from
Aug 16, 2023

Conversation

fmarco76
Copy link
Member

This PR is for porting the change of #4532 and #4534 to master branch.

Additionally, the DefStore is updated with the same code of LDAPStore in order to make both stores consistent.

Finally, the new behaviour requires to modify the action workflow because of different output in some cases.

@fmarco76 fmarco76 requested a review from edewata August 14, 2023 17:35
@fmarco76
Copy link
Member Author

@edewata the majority of this PR has been reviewed, so you can focus only in the few additional changes I have added to port this to master.

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.

Please see my questions/comments about exception handling and log messages. If the current exception handling is safe or has been discussed before no need to change that. Feel free to update/merge. Thanks!

.github/workflows/ocsp-crl-ldap-test.yml Outdated Show resolved Hide resolved
.github/workflows/ocsp-crl-ldap-test.yml Outdated Show resolved Hide resolved
Comment on lines 1391 to 1393
} catch (NoSuchAlgorithmException | IOException e) {
logger.info("CertificateAuthority: OCSP request hash algorithm " + digestName + " not recognised - ");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an unexpected exception, so I'd suggest to log the error message and the stack trace for troubleshooting, e.g.:

logger.error("CertificateAuthority: Unable to generate message digest: " + e.getMessage(), e);

Suppose we have a request with an invalid digestName, what would be the eventual OCSP response? I just want to make sure OCSP won't return a valid response (i.e. good, revoked, unknown) that can be misinterpreted by the OCSP client.

If there's such a risk, it might be better to just let the exception bubble up (i.e. rethrow the exception) and let the OCSP client handle the failure. But if it's OK to ignore, then maybe we should just generate a warning without the stack trace:

logger.warn("CertificateAuthority: Unable to generate message digest: " + e.getMessage());

Copy link
Member Author

@fmarco76 fmarco76 Aug 16, 2023

Choose a reason for hiding this comment

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

The current behaviour is to return "unknown" if the digest does not work. This is done in processRequest() method of the same class. This is acceptable for the protocol because the client should handle this case as this responder cannot validate the certificate and other responders should be invoked.
The protocol provide additional error states which were not used. As an improvement we could implement them to be more accurate in the answer but we can do in a separate PR if it is needed.

However, I think it is better to convert to warning and print the stack trace so these conditions are better identified.

ckelleyRH and others added 9 commits August 16, 2023 11:26
The CA's internal OCSP fails to handle certs issued by an unknown CA.
There is code in the CA's validation to handle that scenario but that
validation is never triggered as the request handling code that wraps it
considers not knowing the origin CA to be an error condition.

The code is changed to allow the validating CA to proceed even if the
origin CA is unknown, reporting Unknown for the CertStatus, while
delegating to the origin CA if it is found.
In case of multiple CAs the correct one was selected using the first
certificate. This could provide inconsistent. Now the selection is based
on the request issuer name.

Additionally, the output has been made consistent with the external OCSP
for all the possibilities of subject and issuers.
a couple things:
- respond with Unknown when CA can't find cert in its db
- added safety net Exception to return Unknown
- minor debug message when CA signs an object that's not a cert

fixes https://bugzilla.redhat.com/show_bug.cgi?id=2221818
minor adjustment for Exception and debug messages.
OCSP requests have the certificate serial number, the hash of CA DN and
the hash of the CA public key. According to the specification, in order
to recognise a request both hashes have to match but the current implementation
was verifying only the public key hash.

This commit add a check on the other hash of the request.
The OCSP responder was failing if CA or CRL were not found. This has been
modified so the responder will provide an `unknown` result in these
cases.
@sonarcloud
Copy link

sonarcloud bot commented Aug 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

0.0% 0.0% Coverage
1.6% 1.6% Duplication

@fmarco76
Copy link
Member Author

@edewata Thanks!

@fmarco76 fmarco76 merged commit 39415a3 into dogtagpki:master Aug 16, 2023
150 checks passed
@fmarco76 fmarco76 deleted the FixOCSPUnknownCA branch August 16, 2023 11:04
@edewata
Copy link
Contributor

edewata commented Aug 16, 2023

Thanks for the update!

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.

4 participants