Skip to content

Commit

Permalink
crypto/x509: add CertPool.Clone
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rolandshoemaker authored and gopherbot committed Apr 13, 2022
1 parent d65a413 commit 9298f60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/next/35044.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg crypto/x509, method (*CertPool) Clone() *CertPool #35044
5 changes: 3 additions & 2 deletions src/crypto/x509/cert_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9298f60

Please sign in to comment.