Add "masterKeyLog" in TLS config (#2758)

* Add "enableMasterKeyLog" in TLS config

Turn on the debug option for Wireshark to decrypt traffic

* Change to "masterKeyLog" to configure a path
This commit is contained in:
yuhan6665 2023-11-27 10:08:34 -05:00 committed by GitHub
parent 2570855cd7
commit 6f092bd212
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 12 deletions

View file

@ -5,6 +5,7 @@ import (
"crypto/tls"
"crypto/x509"
"encoding/base64"
"os"
"strings"
"sync"
"time"
@ -364,6 +365,15 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
config.PreferServerCipherSuites = c.PreferServerCipherSuites
if (len(c.MasterKeyLog) > 0 && c.MasterKeyLog != "none") {
writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644)
if err != nil {
newError("failed to open ", c.MasterKeyLog, " as master key log").AtError().Base(err).WriteToLog()
} else {
config.KeyLogWriter = writer
}
}
return config
}