Skip to content

Commit

Permalink
Add "enableMasterKeyLog" in TLS config
Browse files Browse the repository at this point in the history
Turn on the debug option for Wireshark to decrypt traffic
  • Loading branch information
yuhan6665 committed Nov 26, 2023
1 parent 2570855 commit a3e31c3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
3 changes: 3 additions & 0 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ type TLSConfig struct {
RejectUnknownSNI bool `json:"rejectUnknownSni"`
PinnedPeerCertificateChainSha256 *[]string `json:"pinnedPeerCertificateChainSha256"`
PinnedPeerCertificatePublicKeySha256 *[]string `json:"pinnedPeerCertificatePublicKeySha256"`
EnableMasterKeyLog bool `json:"enableMasterKeyLog"`

This comment has been minimized.

Copy link
@xqzr

xqzr Nov 26, 2023

Contributor

KeyLogFile 字符串

}

// Build implements Buildable.
Expand Down Expand Up @@ -412,6 +413,8 @@ func (c *TLSConfig) Build() (proto.Message, error) {
}
}

config.EnableMasterKeyLog = c.EnableMasterKeyLog

return config, nil
}

Expand Down
4 changes: 2 additions & 2 deletions proxy/wireguard/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions transport/internet/tls/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/tls"
"crypto/x509"
"encoding/base64"
"os"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -364,6 +365,11 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {

config.PreferServerCipherSuites = c.PreferServerCipherSuites

if (c.EnableMasterKeyLog) {

This comment has been minimized.

Copy link
@xqzr

xqzr Nov 26, 2023

Contributor

如果不是 空字符串

writer, _ := os.OpenFile("master.log", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644)

This comment has been minimized.

Copy link
@xqzr

xqzr Nov 26, 2023

Contributor

写入到 KeyLogFile 指定的文件路径

config.KeyLogWriter = writer
}

return config
}

Expand Down
31 changes: 21 additions & 10 deletions transport/internet/tls/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions transport/internet/tls/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ message Config {
@Critical
*/
repeated bytes pinned_peer_certificate_public_key_sha256 = 14;

bool enable_master_key_log = 15;
}

0 comments on commit a3e31c3

Please sign in to comment.