Skip to content

Commit 9298f60

Browse files
rolandshoemakergopherbot
authored andcommitted
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 <[email protected]> Auto-Submit: Roland Shoemaker <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Damien Neil <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent d65a413 commit 9298f60

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

api/next/35044.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkg crypto/x509, method (*CertPool) Clone() *CertPool #35044

src/crypto/x509/cert_pool.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ func (s *CertPool) cert(n int) (*Certificate, error) {
7777
return s.lazyCerts[n].getCert()
7878
}
7979

80-
func (s *CertPool) copy() *CertPool {
80+
// Clone returns a copy of s.
81+
func (s *CertPool) Clone() *CertPool {
8182
p := &CertPool{
8283
byName: make(map[string][]int, len(s.byName)),
8384
lazyCerts: make([]lazyCert, len(s.lazyCerts)),
@@ -109,7 +110,7 @@ func (s *CertPool) copy() *CertPool {
109110
// New changes in the system cert pool might not be reflected in subsequent calls.
110111
func SystemCertPool() (*CertPool, error) {
111112
if sysRoots := systemRootsPool(); sysRoots != nil {
112-
return sysRoots.copy(), nil
113+
return sysRoots.Clone(), nil
113114
}
114115

115116
return loadSystemRoots()

0 commit comments

Comments
 (0)