mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 10:24:40 +01:00
Add suport for TLS key logging
This commit is contained in:
parent
9f86ffdd1e
commit
0c26d1637a
3 changed files with 26 additions and 0 deletions
|
@ -92,6 +92,7 @@ type Config struct {
|
|||
LogMaxBackups int `toml:"log_files_max_backups"`
|
||||
TLSDisableSessionTickets bool `toml:"tls_disable_session_tickets"`
|
||||
TLSCipherSuite []uint16 `toml:"tls_cipher_suite"`
|
||||
TLSKeyLogFile string `toml:"tls_key_log_file"`
|
||||
NetprobeAddress string `toml:"netprobe_address"`
|
||||
NetprobeTimeout int `toml:"netprobe_timeout"`
|
||||
OfflineMode bool `toml:"offline_mode"`
|
||||
|
@ -143,6 +144,7 @@ func newConfig() Config {
|
|||
LogMaxBackups: 1,
|
||||
TLSDisableSessionTickets: false,
|
||||
TLSCipherSuite: nil,
|
||||
TLSKeyLogFile: "",
|
||||
NetprobeTimeout: 60,
|
||||
OfflineMode: false,
|
||||
RefusedCodeInResponses: false,
|
||||
|
@ -628,6 +630,16 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error {
|
|||
proxy.skipAnonIncompatibleResolvers = config.AnonymizedDNS.SkipIncompatible
|
||||
proxy.anonDirectCertFallback = config.AnonymizedDNS.DirectCertFallback
|
||||
|
||||
if len(config.TLSKeyLogFile) > 0 {
|
||||
f, err := os.OpenFile(config.TLSKeyLogFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
|
||||
if err != nil {
|
||||
dlog.Fatalf("Unable to create key log file [%s]: [%s]", config.TLSKeyLogFile, err)
|
||||
}
|
||||
dlog.Warnf("TLS key log file [%s] enabled", config.TLSKeyLogFile)
|
||||
proxy.xTransport.keyLogWriter = f
|
||||
proxy.xTransport.rebuildTransport()
|
||||
}
|
||||
|
||||
if config.DoHClientX509AuthLegacy.Creds != nil {
|
||||
return errors.New("[tls_client_auth] has been renamed to [doh_client_x509_auth] - Update your config file")
|
||||
}
|
||||
|
|
|
@ -223,6 +223,14 @@ cert_refresh_delay = 240
|
|||
# tls_cipher_suite = [52392, 49199]
|
||||
|
||||
|
||||
## Log TLS key material to a file, for debugging purposes only.
|
||||
## This file will contain the TLS master key, which can be used to decrypt
|
||||
## all TLS traffic to/from DoH servers.
|
||||
## Never ever enable except for debugging purposes with a tool such as mitmproxy.
|
||||
|
||||
# tls_key_log_file = '/tmp/keylog.txt'
|
||||
|
||||
|
||||
## Bootstrap resolvers
|
||||
##
|
||||
## These are normal, non-encrypted DNS resolvers, that will be only used
|
||||
|
|
|
@ -75,6 +75,7 @@ type XTransport struct {
|
|||
proxyDialer *netproxy.Dialer
|
||||
httpProxyFunction func(*http.Request) (*url.URL, error)
|
||||
tlsClientCreds DOHClientCreds
|
||||
keyLogWriter io.Writer
|
||||
}
|
||||
|
||||
func NewXTransport() *XTransport {
|
||||
|
@ -93,6 +94,7 @@ func NewXTransport() *XTransport {
|
|||
useIPv6: false,
|
||||
tlsDisableSessionTickets: false,
|
||||
tlsCipherSuite: nil,
|
||||
keyLogWriter: nil,
|
||||
}
|
||||
return &xTransport
|
||||
}
|
||||
|
@ -187,6 +189,10 @@ func (xTransport *XTransport) rebuildTransport() {
|
|||
tlsClientConfig := tls.Config{}
|
||||
certPool, certPoolErr := x509.SystemCertPool()
|
||||
|
||||
if xTransport.keyLogWriter != nil {
|
||||
tlsClientConfig.KeyLogWriter = xTransport.keyLogWriter
|
||||
}
|
||||
|
||||
if clientCreds.rootCA != "" {
|
||||
if certPool == nil {
|
||||
dlog.Fatalf("Additional CAs not supported on this platform: %v", certPoolErr)
|
||||
|
|
Loading…
Add table
Reference in a new issue