-
Notifications
You must be signed in to change notification settings - Fork 52
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
trust_anchor: clarify and rename extract_trust_anchor #201
Conversation
Codecov Report
@@ Coverage Diff @@
## main #201 +/- ##
=======================================
Coverage 96.77% 96.77%
=======================================
Files 20 20
Lines 4772 4774 +2
=======================================
+ Hits 4618 4620 +2
Misses 154 154
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the goals here, but not sure about this particular implementation.
On the naming side, "prevalidated" feels a bit wordy, maybe just used "valid" instead?
On the documentation side, I think you'll find that none of the callers within other rustls packages do much that could be construed as "verification" of subject name, public key and name constraints, so I feel this documentation leans too hard on that idea. In my understanding the way this is generally is used is that the data source is trusted (for example, for webpki-roots the source is the CCADB and for rustls-native-certs is the OS trust store) -- but I don't feel documenting that the caller should verify all the things does a good job of conveying that idea?
I'm happy to iterate further on this 👍
As in "extract_prevalid_trust_anchor" or "extract_valid_trust_anchor"? I'm not sure that either read better to me. "extract_prevalid" feels awkward and "extract_valid" makes it sound like the function does validation and only accepts valid inputs, which is the opposite of what I'm trying to convey here.
I think the key aspect of what you're pointing out is that the callers aren't doing anything that could be construed as verification because they're using a trusted data source that has done that verification. Maybe we can emphasize that instead? I'm not sure I can think of a short name, but something with the spirit of "extract trust anchor from trust store cert"?
As in you think we can't solve this problem with documentation and should consider a different approach? Or am I misunderstanding? |
I think "trust anchor" implies some significant pre-existing validity -- not sure about repeating that in the name of this function. |
What did you think about the discussion in briansmith/webpki#294 ? |
Maybe
Basically what you wrote above. |
03dd414
to
e104674
Compare
SGTM. Renamed. |
Did you also want to adapt the docstring to this thinking? |
It feels to me like the docstring already covers this line of thinking with the following bits of text:
I'm open to suggestions but don't know what other tweaks to make to the current state. |
It still has this:
Which seems to point in the opposite direction. Even the "has already been validated as trustworthy" feels different from maybe more something like "from a source trusted to appropriately validate the certificate" (which feels a little awkward). |
e104674
to
048e814
Compare
I see what you mean 👍 I've iterated on the wording again. Closer to the mark this time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
048e814
to
c5c4590
Compare
This function has caused some confusion w.r.t self-signed end-entity certificates and their support within rustls/webpki. This commit takes two actions: 1. It renames `extract_trust_anchor` to `anchor_from_trusted_cert` to emphasize that the input **must** be from a trusted source that has already evaluated the certificate as suitable for use as a trust anchor. 2. It adds more detail to the rustdoc comment for the function, in particular emphasizing why no additional validations are performed, and that it is not appropriate to use with an end-entity certificate in an attempt to support self-signed certificate use-cases.
c5c4590
to
8692c5f
Compare
@ctz this is super low priority but I'd like to clear this out of my backlog. Do you think the updated text is worthwhile or should I close this PR? I don't feel strongly at this point and mostly just want to come to a decision vs letting it sit longer. WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my opinion on this is that the commentary improvements are all positive. The benefit of the function name change seems quite marginal IMO, but let's go with it.
This function has caused some confusion w.r.t self-signed end-entity certificates and their support within rustls/webpki (see #200, briansmith/webpki#294). This branch takes two actions to try and help this situation:
extract_trust_anchor
toanchor_from_trusted_cert
to emphasize that the input must be prevalidated out-of-band as suitable to use as a trust anchor.