Skip to content

Commit 9abe851

Browse files
committed
Use system cert pool
1 parent 1220d02 commit 9abe851

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

tls/client/roundtripper.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ func WithClientCertsStore(source *source.ClientCertsStore) RoundTripperOption {
3535
}
3636

3737
func WithRootCA(cert *x509.Certificate) RoundTripperOption {
38-
certPool := x509.NewCertPool()
38+
certPool, err := x509.SystemCertPool()
39+
if err != nil {
40+
certPool = x509.NewCertPool()
41+
}
3942
certPool.AddCert(cert)
4043
return WithRootCAs(certPool)
4144
}

tls/client/source/pems.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ func (s ClientPEMs) RootCAs() (*x509.CertPool, error) {
3939
if len(s.RootCAsPEMBlock) == 0 {
4040
return nil, nil
4141
}
42-
certPool := x509.NewCertPool()
42+
certPool, err := x509.SystemCertPool()
43+
if err != nil {
44+
certPool = x509.NewCertPool()
45+
}
4346
if !certPool.AppendCertsFromPEM(s.RootCAsPEMBlock) {
4447
return nil, errors.New("client PEMs: building client CAs failed")
4548
}

tls/server/source/pems.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ func (s ServerPEMs) ClientCAs() (*x509.CertPool, error) {
4040
if len(s.ClientAuthPEMBlock) == 0 {
4141
return nil, nil
4242
}
43-
certPool := x509.NewCertPool()
43+
certPool, err := x509.SystemCertPool()
44+
if err != nil {
45+
certPool = x509.NewCertPool()
46+
}
4447
if !certPool.AppendCertsFromPEM(s.ClientAuthPEMBlock) {
4548
return nil, errors.New("server PEMs: building client CAs failed")
4649
}

0 commit comments

Comments
 (0)