diff --git a/handshake_messages.go b/handshake_messages.go index 52fcf02..3653035 100644 --- a/handshake_messages.go +++ b/handshake_messages.go @@ -1005,6 +1005,7 @@ type encryptedExtensionsMsg struct { quicTransportParameters []byte earlyData bool echRetryConfigs []byte + serverNameAck bool } func (m *encryptedExtensionsMsg) marshal() ([]byte, error) { @@ -1040,6 +1041,10 @@ func (m *encryptedExtensionsMsg) marshal() ([]byte, error) { b.AddBytes(m.echRetryConfigs) }) } + if m.serverNameAck { + b.AddUint16(extensionServerName) + b.AddUint16(0) // empty extension_data + } }) }) @@ -1095,6 +1100,11 @@ func (m *encryptedExtensionsMsg) unmarshal(data []byte) bool { if !extData.CopyBytes(m.echRetryConfigs) { return false } + case extensionServerName: + if len(extData) != 0 { + return false + } + m.serverNameAck = true default: // Ignore unknown extensions. continue diff --git a/handshake_server.go b/handshake_server.go index cb895da..3a2ca85 100644 --- a/handshake_server.go +++ b/handshake_server.go @@ -581,6 +581,10 @@ func (hs *serverHandshakeState) doFullHandshake() error { hs.hello.ocspStapling = true } + if hs.clientHello.serverName != "" { + hs.hello.serverNameAck = true + } + hs.hello.ticketSupported = hs.clientHello.ticketSupported && !c.config.SessionTicketsDisabled hs.hello.cipherSuite = hs.suite.id diff --git a/handshake_server_tls13.go b/handshake_server_tls13.go index ecbfd74..41e303e 100644 --- a/handshake_server_tls13.go +++ b/handshake_server_tls13.go @@ -900,6 +900,10 @@ func (hs *serverHandshakeStateTLS13) sendServerParameters() error { encryptedExtensions.earlyData = hs.earlyData } + if !hs.c.didResume && hs.clientHello.serverName != "" { + encryptedExtensions.serverNameAck = true + } + // If client sent ECH extension, but we didn't accept it, // send retry configs, if available. echKeys := hs.c.config.EncryptedClientHelloKeys