mirror of
https://github.com/XTLS/REALITY.git
synced 2025-08-22 14:38:35 +00:00
crypto/tls: empty server_name conf. ext. from server
When a TLS server uses the information from the server_name extension in a client hello, and the connection isn't resuming, it should return an empty server_name extension in its server hello (or encrypted extensions for TLS 1.3). For TLS <1.3 we we do this in doFullHandshake(), by setting the pre-existing serverHelloMsg.serverNameAck bool. We know that the connection isn't resuming based on the context where this function is called. For TLS 1.3, a new encryptedExtensionsMsg.serverNameAck bool is added, and populated as appropriate in sendServerParameters() based on whether the conn was resumed or not. The encryptedExtensionsMsg marshalling is updated to emit the encrypted extension based on that field. These changes allow enabling the ServerNameExtensionServer-* bogo tests that verify both the presence and absence of the server_name extension based on the relevant specifications. Resolves #74282 Updates #72006 Change-Id: I703bc2ec916b50906bdece7b7483a7faed7aa8e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/684795 TryBot-Bypass: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> Auto-Submit: Daniel McCarney <daniel@binaryparadox.net>
This commit is contained in:
parent
722d440e19
commit
4f8fcee58e
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user