Skip to content

Commit feccfb8

Browse files
committed
crypto/x509: use fingerprint map for (*CertPool).contains
This fell through the cracks from the CL 229917 comments. Change-Id: I22584107f1e8111f9c523f45307dd50e1e5f4b8f Reviewed-on: https://go-review.googlesource.com/c/go/+/268339 Trust: Filippo Valsorda <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent f858c22 commit feccfb8

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/crypto/x509/cert_pool.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,7 @@ func (s *CertPool) contains(cert *Certificate) bool {
161161
if s == nil {
162162
return false
163163
}
164-
candidates := s.byName[string(cert.RawSubject)]
165-
for _, i := range candidates {
166-
c, err := s.cert(i)
167-
if err != nil {
168-
return false
169-
}
170-
if c.Equal(cert) {
171-
return true
172-
}
173-
}
174-
175-
return false
164+
return s.haveSum[sha256.Sum224(cert.Raw)]
176165
}
177166

178167
// AddCert adds a certificate to a pool.

0 commit comments

Comments
 (0)