-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
crypto/x509: add CertPool.Equal #46057
Comments
In recent versions of Go, CertPool now internally represents a lazy set of certificates that might not be fully loaded yet. What does "Equal" mean in this proposal? Would you want it to load them all from disk if they weren't yet? Can you give some background on when you'd use this? |
Yes, I believe this change is what prevents #45891 has some context. We have tests that used I would expect |
This proposal has been added to the active column of the proposals project |
for right now we are only comparing the Subject until the issue is resolved Context: golang/go#46057
/cc @FiloSottile for whether this is a reasonable API addition |
Talked to Filippo and he said this was reasonable to do. We are planning to keep the cert pools opaque when they are derived from the system pool, but it is easy to tell if two different pools both include the system pool or not. Does anyone object to this? |
Does anyone actually have a non-test use for this? Or is this something that comes up at all commonly? It sounds like it could end up being an unexpectedly slow and heavy-weight function. |
@tmthrgd Filippo says it can be implemented efficiently. The definition of CertPool.Equal would be "same 'use system pool' setting and same additional certificates". So the system pool itself need not be consulted for implementing Equal. |
Based on the discussion above, this proposal seems like a likely accept. |
More than happy to be wrong, but I was basing that off of this request/requirement above: “I would expect Equal to load all the content from disk and compare the content using reflect.DeepEqual[.]” That sounded deceptively expensive to me. Though if it’s not expensive, there doesn’t seem to be any real reason to oppose it. |
To be clear, it won't. It will just compare whether two CertPools both say "include what's on disk" or not. |
No change in consensus, so accepted. 🎉 |
Change https://go.dev/cl/388915 mentions this issue: |
Change https://go.dev/cl/398237 mentions this issue: |
CL 388915 added an exported API but was authored (and tested) before the API check became stricter. Updates #46057. Change-Id: Iee6e4969ade77fb0539fa97fcef0047389fb2cf6 Reviewed-on: https://go-review.googlesource.com/c/go/+/398237 Trust: Dmitri Shuralyov <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]>
@rolandshoemaker Under what conditions are two |
What version of Go are you using (
go version
)?go 1.16.x
What did you expect to see?
In response to #45891,
x509.CertPool
structs can no longer be compared withreflect.DeepEqual
, and there is no way to export the certificates, so there is no longer any way to fully compare these structs.CertPool.Subjects
can be used for a shallow comparison, but #45891 (comment) shows that this is not a complete comparison.By adding an
Equal(other CertPool) bool
these types can be compared directly, and go-cmp will automatically use the method for comparison.The text was updated successfully, but these errors were encountered: