-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
Go version
go version go1.21.6 linux/amd64
Output of go env
in your module/workspace:
[...]
What did you do?
Called crypto/tls tls.Client() to connect to particular TLS server with TLS 1.3.
What did you see happen?
Error: "tls: received record with version 301 when expecting version 303".
What did you expect to see?
Successful connection, no error.
I believe this is a side effect of TLS version field enforcement while reading TLS records. See these particular lines in conn.go:
Line 655 in c83b1a7
if expectedVers == VersionTLS13 { |
and
Line 661 in c83b1a7
if c.haveVers && vers != expectedVers { |
Although legacy_record_version must indeed be set to 0x0303, - as by RFC 8446 Section 5.1, - "for all records generated by a TLS 1.3 implementation other than an initial ClientHello", the very same paragraph of RFC 8446 clearly requires to otherwise ignore the legacy_record_version value, as "[t]his field is deprecated". It seems that client reading TLS records for TLS 1.3 should tolerate "wrong value" discovered in record header, possibly by completely ignoring it. And this was the exact case before version enforcement, thus enabling successful TLS 1.3 connections to some "buggy" servers, which is no longer possible with newer crypto/tls. Please, consider reverting to former version-tolerant variant.