From 5f5c7a11444cec7ab3f94470f31290a2802ccb74 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:25:08 -0400 Subject: [PATCH] crypto/tls: remove the tlsunsafeekm GODEBUG setting Updates #75316 Change-Id: I2efa3e485653f5b403d92e5d99959e356a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/777380 Reviewed-by: Roland Shoemaker Auto-Submit: Filippo Valsorda Reviewed-by: David Chase LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com --- common.go | 5 ----- conn.go | 8 +------- prf.go | 2 +- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/common.go b/common.go index c3ed291..4b8aba8 100644 --- a/common.go +++ b/common.go @@ -338,11 +338,6 @@ type ConnectionState struct { // the seed. If the connection was set to allow renegotiation via // Config.Renegotiation, or if the connections supports neither TLS 1.3 nor // Extended Master Secret, this function will return an error. -// -// Exporting key material without Extended Master Secret or TLS 1.3 was disabled -// in Go 1.22 due to security issues (see the Security Considerations sections -// of RFC 5705 and RFC 7627), but can be re-enabled with the GODEBUG setting -// tlsunsafeekm=1. func (cs *ConnectionState) ExportKeyingMaterial(label string, context []byte, length int) ([]byte, error) { return cs.ekm(label, context, length) } diff --git a/conn.go b/conn.go index 3bcca8b..8ac81a6 100644 --- a/conn.go +++ b/conn.go @@ -1703,13 +1703,7 @@ func (c *Conn) connectionStateLocked() ConnectionState { if c.config.Renegotiation != RenegotiateNever { state.ekm = noEKMBecauseRenegotiation } else if c.vers != VersionTLS13 && !c.extMasterSecret { - state.ekm = func(label string, context []byte, length int) ([]byte, error) { - // if ekmgodebug.Value() == "1" { - // ekmgodebug.IncNonDefault() - // return c.ekm(label, context, length) - // } - return noEKMBecauseNoEMS(label, context, length) - } + state.ekm = noEKMBecauseNoEMS } else { state.ekm = c.ekm } diff --git a/prf.go b/prf.go index f288642..a0e51d2 100644 --- a/prf.go +++ b/prf.go @@ -250,7 +250,7 @@ func noEKMBecauseRenegotiation(label string, context []byte, length int) ([]byte // Master Secret is not negotiated and thus we wish to fail all key-material // export requests. func noEKMBecauseNoEMS(label string, context []byte, length int) ([]byte, error) { - return nil, errors.New("crypto/tls: ExportKeyingMaterial is unavailable when neither TLS 1.3 nor Extended Master Secret are negotiated; override with GODEBUG=tlsunsafeekm=1") + return nil, errors.New("crypto/tls: ExportKeyingMaterial is unavailable when neither TLS 1.3 nor Extended Master Secret are negotiated") } // ekmFromMasterSecret generates exported keying material as defined in RFC 5705.