feat(client): verify server certificates against the system root store (#5546)

transport.tls.trustedCaFile is installed as RootCAs, and omitting it sets
InsecureSkipVerify, so system-root verification cannot be selected directly.
Add an opt-in transport.tls.useSystemRoots that enables certificate
verification with RootCAs nil when no trusted CA file is set, allowing Go to
use system roots and native verification on macOS and Windows. Defaults are
unchanged.
This commit is contained in:
Alexey Sviridov
2026-10-18 14:08:05 +08:00
committed by GitHub
parent 954f918d0c
commit 7441443134
8 changed files with 176 additions and 6 deletions
+3
View File
@@ -175,6 +175,9 @@ type TLSClientConfig struct {
// first custom byte when tls is enabled.
// Since v0.50.0, the default value has been changed to true, and the first custom byte is disabled by default.
DisableCustomTLSFirstByte *bool `json:"disableCustomTLSFirstByte,omitempty"`
// UseSystemRoots enables server certificate verification using system roots.
// TrustedCaFile takes precedence. If neither is configured, verification is disabled.
UseSystemRoots bool `json:"useSystemRoots,omitempty"`
TLSConfig
}