From ff518ab8eb7f964f56c151f92ca674e10bec6aa4 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 10 Sep 2026 22:57:20 -0400 Subject: [PATCH] crypto/tls: wrap KeyLogWriter errors w/ prefix If a tls.Config populates a KeyLogWriter, and the io.Writer's Write() returns an error when using it in writeKeyLog() we should wrap the error with a prefix that indicates the source to aid in debugging. Fixes #79392 Change-Id: Ie16bb2908575123a8e80c623a15f3835a7bc3e92 Reviewed-on: https://go-review.googlesource.com/c/go/+/784740 Reviewed-by: Roland Shoemaker Auto-Submit: Daniel McCarney Reviewed-by: Neal Patel LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com Reviewed-by: Neal Patel --- common.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common.go b/common.go index 2655ead..155bfc5 100644 --- a/common.go +++ b/common.go @@ -1650,7 +1650,10 @@ func (c *Config) writeKeyLog(label string, clientRandom, secret []byte) error { _, err := c.KeyLogWriter.Write(logLine) writerMutex.Unlock() - return err + if err != nil { + return fmt.Errorf("tls: KeyLogWriter: %w", err) + } + return nil } // writerMutex protects all KeyLogWriters globally. It is rarely enabled,