From edf00b752df586b81e8cac3d021b713992e37ac1 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 14 Oct 2023 09:41:04 -0400 Subject: [PATCH] crypto/tls: advertise correct ciphers in TLS 1.3 only mode This change updates the makeClientHello logic to only advertise TLS 1.3 ciphers when tls.Config.MinVersion is set to tls.VersionTLS13 (i.e the client only supports TLS 1.3). Previously, TLS 1.2 ciphers would be included in the client hello message. Fixes #57771 Change-Id: Ife4123037b0a4609578ffffb1cdf1e1d4e0a8df6 GitHub-Last-Rev: 45f4275 GitHub-Pull-Request: #49293 Reviewed-on: https://go-review.googlesource.com/c/go/+/360794 Reviewed-by: Filippo Valsorda Run-TryBot: Filippo Valsorda Reviewed-by: Roland Shoemaker Reviewed-by: Damien Neil Reviewed-by: Marten Seemann Auto-Submit: Filippo Valsorda TryBot-Result: Gopher Robot --- handshake_client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/handshake_client.go b/handshake_client.go index daed95b..cb56ca5 100644 --- a/handshake_client.go +++ b/handshake_client.go @@ -133,6 +133,10 @@ func (c *Conn) makeClientHello() (*clientHelloMsg, *ecdh.PrivateKey, error) { var key *ecdh.PrivateKey if hello.supportedVersions[0] == VersionTLS13 { + // Reset the list of ciphers when the client only supports TLS 1.3. + if len(hello.supportedVersions) == 1 { + hello.cipherSuites = nil + } if hasAESGCMHardwareSupport { hello.cipherSuites = append(hello.cipherSuites, defaultCipherSuitesTLS13...) } else {