add default server name for tls client config
This commit is contained in:
parent
09ee29091b
commit
a0765edd40
@ -2,6 +2,7 @@ package parsing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -94,10 +95,18 @@ func ParseHop(cfg *config.HopConfig) (chain.Hop, error) {
|
|||||||
"dialer": v.Dialer.Type,
|
"dialer": v.Dialer.Type,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
serverName, _, _ := net.SplitHostPort(v.Addr)
|
||||||
|
if serverName == "" {
|
||||||
|
serverName = "localhost"
|
||||||
|
}
|
||||||
|
|
||||||
tlsCfg := v.Connector.TLS
|
tlsCfg := v.Connector.TLS
|
||||||
if tlsCfg == nil {
|
if tlsCfg == nil {
|
||||||
tlsCfg = &config.TLSConfig{}
|
tlsCfg = &config.TLSConfig{}
|
||||||
}
|
}
|
||||||
|
if tlsCfg.ServerName == "" {
|
||||||
|
tlsCfg.ServerName = serverName
|
||||||
|
}
|
||||||
tlsConfig, err := tls_util.LoadClientConfig(
|
tlsConfig, err := tls_util.LoadClientConfig(
|
||||||
tlsCfg.CertFile, tlsCfg.KeyFile, tlsCfg.CAFile,
|
tlsCfg.CertFile, tlsCfg.KeyFile, tlsCfg.CAFile,
|
||||||
tlsCfg.Secure, tlsCfg.ServerName)
|
tlsCfg.Secure, tlsCfg.ServerName)
|
||||||
@ -137,6 +146,9 @@ func ParseHop(cfg *config.HopConfig) (chain.Hop, error) {
|
|||||||
if tlsCfg == nil {
|
if tlsCfg == nil {
|
||||||
tlsCfg = &config.TLSConfig{}
|
tlsCfg = &config.TLSConfig{}
|
||||||
}
|
}
|
||||||
|
if tlsCfg.ServerName == "" {
|
||||||
|
tlsCfg.ServerName = serverName
|
||||||
|
}
|
||||||
tlsConfig, err = tls_util.LoadClientConfig(
|
tlsConfig, err = tls_util.LoadClientConfig(
|
||||||
tlsCfg.CertFile, tlsCfg.KeyFile, tlsCfg.CAFile,
|
tlsCfg.CertFile, tlsCfg.KeyFile, tlsCfg.CAFile,
|
||||||
tlsCfg.Secure, tlsCfg.ServerName)
|
tlsCfg.Secure, tlsCfg.ServerName)
|
||||||
|
Loading…
Reference in New Issue
Block a user