Skip to content

Commit

Permalink
Apply DefaultServerName more broadly during handshake (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
mholt authored May 13, 2024
1 parent 2ef8fdf commit 8ac11fa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (cfg *Config) getCertificateFromCache(hello *tls.ClientHelloInfo) (cert Cer
}
}

// fall back to a "default" certificate, if specified
// use a "default" certificate by name, if specified
if cfg.DefaultServerName != "" {
normDefault := normalizedName(cfg.DefaultServerName)
cert, defaulted = cfg.selectCert(hello, normDefault)
Expand Down Expand Up @@ -835,10 +835,13 @@ func (cfg *Config) getTLSALPNChallengeCert(clientHello *tls.ClientHelloInfo) (*t
// getNameFromClientHello returns a normalized form of hello.ServerName.
// If hello.ServerName is empty (i.e. client did not use SNI), then the
// associated connection's local address is used to extract an IP address.
func (*Config) getNameFromClientHello(hello *tls.ClientHelloInfo) string {
func (cfg *Config) getNameFromClientHello(hello *tls.ClientHelloInfo) string {
if name := normalizedName(hello.ServerName); name != "" {
return name
}
if cfg.DefaultServerName != "" {
return normalizedName(cfg.DefaultServerName)
}
return localIPFromConn(hello.Conn)
}

Expand Down

0 comments on commit 8ac11fa

Please sign in to comment.