Skip to content

Commit 8ac11fa

Browse files
authored
Apply DefaultServerName more broadly during handshake (#287)
1 parent 2ef8fdf commit 8ac11fa

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

handshake.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (cfg *Config) getCertificateFromCache(hello *tls.ClientHelloInfo) (cert Cer
123123
}
124124
}
125125

126-
// fall back to a "default" certificate, if specified
126+
// use a "default" certificate by name, if specified
127127
if cfg.DefaultServerName != "" {
128128
normDefault := normalizedName(cfg.DefaultServerName)
129129
cert, defaulted = cfg.selectCert(hello, normDefault)
@@ -835,10 +835,13 @@ func (cfg *Config) getTLSALPNChallengeCert(clientHello *tls.ClientHelloInfo) (*t
835835
// getNameFromClientHello returns a normalized form of hello.ServerName.
836836
// If hello.ServerName is empty (i.e. client did not use SNI), then the
837837
// associated connection's local address is used to extract an IP address.
838-
func (*Config) getNameFromClientHello(hello *tls.ClientHelloInfo) string {
838+
func (cfg *Config) getNameFromClientHello(hello *tls.ClientHelloInfo) string {
839839
if name := normalizedName(hello.ServerName); name != "" {
840840
return name
841841
}
842+
if cfg.DefaultServerName != "" {
843+
return normalizedName(cfg.DefaultServerName)
844+
}
842845
return localIPFromConn(hello.Conn)
843846
}
844847

0 commit comments

Comments
 (0)