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 <roland@golang.org>
Auto-Submit: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Neal Patel <neal@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Neal Patel <nealpatel@google.com>
This commit is contained in:
yuhan6665
2026-09-10 22:57:20 -04:00
parent 0b8071916e
commit ff518ab8eb
+4 -1
View File
@@ -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,