crypto/x509: add CertPool.Clone

Export the previously private method copy as Clone.

Fixes #35044

Change-Id: I5403d6a3b9f344c980c1c89a6823e1a49dcda26b
Reviewed-on: https://go-review.googlesource.com/c/go/+/400175
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Roland Shoemaker 2022-04-13 11:49:15 -07:00 committed by Gopher Robot
parent d65a41329e
commit 9298f604f4
2 changed files with 4 additions and 2 deletions

1
api/next/35044.txt Normal file
View File

@ -0,0 +1 @@
pkg crypto/x509, method (*CertPool) Clone() *CertPool #35044

View File

@ -77,7 +77,8 @@ func (s *CertPool) cert(n int) (*Certificate, error) {
return s.lazyCerts[n].getCert()
}
func (s *CertPool) copy() *CertPool {
// Clone returns a copy of s.
func (s *CertPool) Clone() *CertPool {
p := &CertPool{
byName: make(map[string][]int, len(s.byName)),
lazyCerts: make([]lazyCert, len(s.lazyCerts)),
@ -109,7 +110,7 @@ func (s *CertPool) copy() *CertPool {
// New changes in the system cert pool might not be reflected in subsequent calls.
func SystemCertPool() (*CertPool, error) {
if sysRoots := systemRootsPool(); sysRoots != nil {
return sysRoots.copy(), nil
return sysRoots.Clone(), nil
}
return loadSystemRoots()