Skip to content

Correct purpose setting for OCSP_request_verify#3089

Merged
samuel40791765 merged 3 commits intoaws:mainfrom
samuel40791765:fix-ocsp-verify
Mar 16, 2026
Merged

Correct purpose setting for OCSP_request_verify#3089
samuel40791765 merged 3 commits intoaws:mainfrom
samuel40791765:fix-ocsp-verify

Conversation

@samuel40791765
Copy link
Contributor

Fixes a logic error from &&|| in OCSP_request_verify when initializing the store context and setting its purpose. With &&, a set_purpose failure is silently ignored when init succeeds, so X509_verify_cert runs without X509_PURPOSE_OCSP_HELPER.

OCSP_HELPER is already intentionally permissive (skips leaf EKU checks, uses basic self-signed root trust), and the default path without it behaves nearly the same way. The signature is already validated before this point.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.18%. Comparing base (32bba49) to head (f369d06).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crypto/ocsp/ocsp_verify.c 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3089      +/-   ##
==========================================
- Coverage   78.19%   78.18%   -0.02%     
==========================================
  Files         689      689              
  Lines      121814   121822       +8     
  Branches    16995    16994       -1     
==========================================
- Hits        95254    95246       -8     
- Misses      25676    25689      +13     
- Partials      884      887       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

justsmth
justsmth previously approved these changes Mar 13, 2026
// Initialize and set purpose of |ctx| for verification.
if (!X509_STORE_CTX_init(ctx, store, signer, NULL) &&
if (!X509_STORE_CTX_init(ctx, store, signer, NULL) ||
!X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_OCSP_HELPER)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

NP: We could also make these success values explicit:

    if (1 != X509_STORE_CTX_init(ctx, store, signer, NULL) ||
        1 != X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_OCSP_HELPER)) {

return 0;
}
if (1 != X509_pubkey_digest(cert, dgst, md, NULL)) {
if (1 == X509_pubkey_digest(cert, dgst, md, NULL)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we error if this fails?

@samuel40791765 samuel40791765 merged commit bae9cde into aws:main Mar 16, 2026
454 of 456 checks passed
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