mirror of
https://github.com/luscis/openlan.git
synced 2025-12-24 11:10:54 +08:00
proxy: fix loading system trusted ca.
This commit is contained in:
@@ -284,19 +284,18 @@ func (t *HttpProxy) openConn(protocol, remote string, insecure bool) (net.Conn,
|
||||
}
|
||||
caFile := t.cfg.CaCert
|
||||
if caFile != "" && libol.FileExist(caFile) == nil {
|
||||
caCertPool := x509.NewCertPool()
|
||||
roots, err := x509.SystemCertPool()
|
||||
// Load CA cert
|
||||
caCert, err := os.ReadFile(caFile)
|
||||
if err != nil {
|
||||
t.out.Warn("HttpProxy.openConn %s", err)
|
||||
} else {
|
||||
caCertPool.AppendCertsFromPEM(caCert)
|
||||
conf.RootCAs = caCertPool
|
||||
roots.AppendCertsFromPEM(caCert)
|
||||
conf.RootCAs = roots
|
||||
}
|
||||
}
|
||||
dialer := &net.Dialer{Timeout: 10 * time.Second}
|
||||
return tls.DialWithDialer(dialer, "tcp", remote, conf)
|
||||
|
||||
}
|
||||
return net.DialTimeout("tcp", remote, 10*time.Second)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user