Support SSLKEYLOGFILE environment variable for secrets logging

This commit is contained in:
Igor Wiedler 2021-07-27 16:13:25 +02:00
parent 59a32e5eb0
commit e9f48103f9
1 changed files with 8 additions and 0 deletions

View File

@ -542,6 +542,14 @@ func ClientTransportCredentials(insecureSkipVerify bool, cacertFile, clientCertF
tlsConf.RootCAs = certPool
}
if os.Getenv("SSLKEYLOGFILE") != "" {
w, err := os.OpenFile(os.Getenv("SSLKEYLOGFILE"), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
return nil, fmt.Errorf("could not open SSLKEYLOGFILE: %v", err)
}
tlsConf.KeyLogWriter = w
}
return credentials.NewTLS(&tlsConf), nil
}