mirror of
https://github.com/fatedier/frp.git
synced 2026-10-19 01:13:27 +08:00
feat(client): add useSystemCa and combine it with trustedCaFile (#5572)
Move the frpc-only TLS option into the shared TLSConfig as transport.tls.useSystemCa, replacing the unpublished useSystemRoots. When set, frpc verifies the server with the system CAs; when trustedCaFile is also set, its CAs are appended to the system pool so both are trusted. Failures to load either source abort the connection instead of falling back. Enabling the option without effective TLS is a configuration error, and the field is rejected in frps transport.tls and in both webServer.tls sections. Fixes #5545
This commit is contained in:
+4
-4
@@ -109,12 +109,12 @@ func (c *defaultConnectorImpl) Open() error {
|
||||
sn = c.cfg.ServerAddr
|
||||
}
|
||||
if lo.FromPtr(c.cfg.Transport.TLS.Enable) {
|
||||
tlsConfig, err = transport.NewClientTLSConfigWithSystemRoots(
|
||||
tlsConfig, err = transport.NewClientTLSConfigWithSystemCA(
|
||||
c.cfg.Transport.TLS.CertFile,
|
||||
c.cfg.Transport.TLS.KeyFile,
|
||||
c.cfg.Transport.TLS.TrustedCaFile,
|
||||
sn,
|
||||
c.cfg.Transport.TLS.UseSystemRoots)
|
||||
c.cfg.Transport.TLS.UseSystemCa)
|
||||
} else {
|
||||
tlsConfig, err = transport.NewClientTLSConfig("", "", "", sn)
|
||||
}
|
||||
@@ -195,12 +195,12 @@ func (c *defaultConnectorImpl) realConnect() (net.Conn, error) {
|
||||
sn = c.cfg.ServerAddr
|
||||
}
|
||||
|
||||
tlsConfig, err = transport.NewClientTLSConfigWithSystemRoots(
|
||||
tlsConfig, err = transport.NewClientTLSConfigWithSystemCA(
|
||||
c.cfg.Transport.TLS.CertFile,
|
||||
c.cfg.Transport.TLS.KeyFile,
|
||||
c.cfg.Transport.TLS.TrustedCaFile,
|
||||
sn,
|
||||
c.cfg.Transport.TLS.UseSystemRoots)
|
||||
c.cfg.Transport.TLS.UseSystemCa)
|
||||
if err != nil {
|
||||
xl.Warnf("fail to build tls configuration, err: %v", err)
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user