From: Nicola Murino Date: Sun, 24 Nov 2024 14:28:34 +0000 (+0100) Subject: crypto/tls: add offered cipher suites to the handshake error X-Git-Tag: go1.25rc1~533 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3046b499918929944cbce1c0ed14c14d0b431adf;p=gostls13.git crypto/tls: add offered cipher suites to the handshake error This change makes debugging easier if the server handshake fails because the client only offers unsupported algorithms. Change-Id: I7daac173a16af2e073aec3d9b59709560f540c6f Reviewed-on: https://go-review.googlesource.com/c/go/+/631555 Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Reviewed-by: Filippo Valsorda Reviewed-by: Roland Shoemaker Auto-Submit: Nicola Murino --- diff --git a/src/crypto/tls/handshake_server.go b/src/crypto/tls/handshake_server.go index 68c14b8a5a..507b69a0ed 100644 --- a/src/crypto/tls/handshake_server.go +++ b/src/crypto/tls/handshake_server.go @@ -378,7 +378,8 @@ func (hs *serverHandshakeState) pickCipherSuite() error { hs.suite = selectCipherSuite(preferenceList, hs.clientHello.cipherSuites, hs.cipherSuiteOk) if hs.suite == nil { c.sendAlert(alertHandshakeFailure) - return errors.New("tls: no cipher suite supported by both client and server") + return fmt.Errorf("tls: no cipher suite supported by both client and server; client offered: %x", + hs.clientHello.cipherSuites) } c.cipherSuite = hs.suite.id diff --git a/src/crypto/tls/handshake_server_tls13.go b/src/crypto/tls/handshake_server_tls13.go index 929d865dd4..ab0cff9e28 100644 --- a/src/crypto/tls/handshake_server_tls13.go +++ b/src/crypto/tls/handshake_server_tls13.go @@ -16,6 +16,7 @@ import ( "crypto/rsa" "crypto/tls/internal/fips140tls" "errors" + "fmt" "hash" "internal/byteorder" "io" @@ -190,7 +191,8 @@ func (hs *serverHandshakeStateTLS13) processClientHello() error { } if hs.suite == nil { c.sendAlert(alertHandshakeFailure) - return errors.New("tls: no cipher suite supported by both client and server") + return fmt.Errorf("tls: no cipher suite supported by both client and server; client offered: %x", + hs.clientHello.cipherSuites) } c.cipherSuite = hs.suite.id hs.hello.cipherSuite = hs.suite.id