Skip to content

Expose builder-like interface for path verification#486

Merged
djc merged 7 commits into
mainfrom
path-builder
May 9, 2026
Merged

Expose builder-like interface for path verification#486
djc merged 7 commits into
mainfrom
path-builder

Conversation

@djc
Copy link
Copy Markdown
Member

@djc djc commented May 3, 2026

Avoids the many-argument verify_for_usage() complexity bottleneck in favor of exposing the underlying ChainOptions directly (under a different name). Should make it easier to evolve this API going forward (as suggested in #485).

@djc djc requested a review from ctz May 3, 2026 13:10
@djc djc force-pushed the path-builder branch from f53ba80 to 7c20605 Compare May 3, 2026 13:11
Comment thread src/verify_cert.rs Outdated
// Use `'a` for lifetimes that we don't care about, `'p` for lifetimes that become a part of
// the `VerifiedPath`.
pub(crate) struct ChainOptions<'a, 'p> {
pub(crate) struct PathBuilder<'a, 'p> {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not sure this is the best name? I wanted to evoke "path building" but maybe that's too jargony and it would be better to stick with "verification" or "verifier" language.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.01%. Comparing base (55a52f3) to head (22fe08e).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #486      +/-   ##
==========================================
+ Coverage   96.97%   97.01%   +0.03%     
==========================================
  Files          20       20              
  Lines        3936     3950      +14     
==========================================
+ Hits         3817     3832      +15     
+ Misses        119      118       -1     

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

@djc djc force-pushed the path-builder branch from 7c20605 to a5ede90 Compare May 3, 2026 13:15
@djc djc requested a review from cpu May 3, 2026 13:16
@djc djc force-pushed the path-builder branch from a5ede90 to 5e23eeb Compare May 3, 2026 13:16
Comment thread src/verify_cert.rs Outdated
@ctz
Copy link
Copy Markdown
Member

ctz commented May 7, 2026

LGTM!

@djc djc force-pushed the path-builder branch from 5e23eeb to 22fe08e Compare May 9, 2026 12:23
@djc djc enabled auto-merge May 9, 2026 12:24
@djc djc added this pull request to the merge queue May 9, 2026
Merged via the queue into main with commit 0fe5e6c May 9, 2026
27 checks passed
@djc djc deleted the path-builder branch May 9, 2026 12:28
Copy link
Copy Markdown
Contributor

@briansmith briansmith left a comment

Choose a reason for hiding this comment

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

I think that this is a good and necessary thing to do. But, I think that the new design now errs too far on making it too easy for the user to skip adding universally-essential inputs prior to calling build. It matters less now that there isn't a way to do things like AIA-based intermediate fetching, but if/when extension points are added that would allow that in the future (e.g. to support things like Firefox's preloaded intermediate allowlist), an application could easily end up "working" during testing but fail in usual cases.

Comment thread src/verify_cert.rs
/// public key is not validated against this list.
/// * `trust_anchors` is the list of root CAs to trust in the built path.
pub fn new(
eku: &'p dyn ExtendedKeyUsageValidator,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ExtendedKeyUsageValidator is not a sealed trait so this supports arbitrary user-implemented EKU matching, including EKU matching that is totally broken (no-op), right?

If it is necessary to have such custom functionality, perhaps there could be a separate not_for_webpki() constructor that takes a &dyn ExtendedKeyUsageValidator, while having new take a concrete WebPKI-relevant OID for eku.

(Also, KeyUsage is a misleading name for the library-provided implementation of this type, because in X.509 KeyUsage is a different thing.)

Comment thread src/verify_cert.rs
/// Set the sequence of intermediate certificates to use for path building.
///
/// These should be sent by the peer. Defaults to empty.
pub fn with_intermediate_certs(mut self, intermediate_certs: &'p [CertificateDer<'p>]) -> Self {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In almost any real-world WebPKI implementation, failing to supply intermediate certificates as input into the validation is going to result in bad behavior, so IMO the intermediate certificates should be parameters to new or there should be some other mechanism to statically ensure that this step isn't skipped.

Comment thread src/verify_cert.rs
///
/// By default, revocation checking is disabled.
pub fn with_revocation(mut self, revocation: RevocationOptions<'a>) -> Self {
self.revocation = Some(revocation);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Every X.509 application has to make an explicit decision on what to do about revocation, so again, I think there should be some mechanism to ensure this isn't skipped.

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