Skip to content

Fix CRL selection by cRLNumber and scope#491

Open
xyzzyz wants to merge 1 commit into
rustls:mainfrom
xyzzyz:fix-crl-selection
Open

Fix CRL selection by cRLNumber and scope#491
xyzzyz wants to merge 1 commit into
rustls:mainfrom
xyzzyz:fix-crl-selection

Conversation

@xyzzyz
Copy link
Copy Markdown

@xyzzyz xyzzyz commented May 13, 2026

Fixes the issue in #488.

Previously, we used the first CRL with applicable scope on the passed list, without checking that it's the newest one we have.

In the new logic, once we find a CRL with applicable scope, we find the newest available CRL in the same scope, and use that for revocation check. We decide which is newest by CRL number, as RFC 5280 explicitly requires these to be present, and offers them for exactly this purpose:

5.2.3. CRL Number
The CRL number is a non-critical CRL extension that conveys a
monotonically increasing sequence number for a given CRL scope and
CRL issuer. This extension allows users to easily determine when a
particular CRL supersedes another CRL. CRL numbers also support the
identification of complementary complete CRLs and delta CRLs. CRL
issuers conforming to this profile MUST include this extension in all
CRLs and MUST mark this extension as non-critical.

There are some design considerations for handling scenarios when multiple scopes are applicable, and when some CRLs are invalid. These apply to pre-existing code too, so I'm not resolving these in this fix, and instead I'll open a separate issue to discuss them.

I used Codex GPT-5.5 on xhigh while working on this change, but I must say that it while it was very helpful with writing tests, it didn't do a good job on implementing the actual logic: its implementation was overly complicated, with extra unnecessary variables and unnecessarily nested match cases. I basically entirely rewrote it.

Previously, we used the first CRL with applicable scope on the passed list,
without checking that it's the newest one we have.

In the new logic, once we find a CRL with applicable scope, we find the
newest available CRL in the same scope, and use that for revocation check.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 91.52542% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.92%. Comparing base (0fe5e6c) to head (b1a205f).

Files with missing lines Patch % Lines
src/crl/types.rs 87.50% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #491      +/-   ##
==========================================
- Coverage   97.01%   96.92%   -0.10%     
==========================================
  Files          20       20              
  Lines        3950     3996      +46     
==========================================
+ Hits         3832     3873      +41     
- Misses        118      123       +5     

☔ 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.

@xyzzyz
Copy link
Copy Markdown
Author

xyzzyz commented May 13, 2026

Regarding the code coverage results:

For this one:
image

it would be difficult to add coverage for this line in test: it would require deliberately creating an invalid CRL (one with missing CRL number). I made CRL number optional, because the library has not previously rejected CRLs without CRL number (even though RFC 5280 requires it). I could simplify code by requiring CRL number to be present. Should I do it? I think it's a good idea, because the change would only be observable on CRLs that we should be ignoring anyway.

For this one:

image

The library already didn't have coverage for hash, so I'm not sure if I should add this in this PR.

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.

1 participant