mirror of
https://github.com/fullstorydev/grpcurl.git
synced 2026-05-22 19:51:44 +03:00
Support SSLKEYLOGFILE environment variable for key logging (#245)
This commit is contained in:
@@ -408,12 +408,22 @@ func main() {
|
||||
}
|
||||
var creds credentials.TransportCredentials
|
||||
if !*plaintext {
|
||||
var err error
|
||||
creds, err = grpcurl.ClientTransportCredentials(*insecure, *cacert, *cert, *key)
|
||||
tlsConf, err := grpcurl.ClientTLSConfig(*insecure, *cacert, *cert, *key)
|
||||
if err != nil {
|
||||
fail(err, "Failed to configure transport credentials")
|
||||
fail(err, "Failed to create TLS config")
|
||||
}
|
||||
|
||||
sslKeylogFile := os.Getenv("SSLKEYLOGFILE")
|
||||
if sslKeylogFile != "" {
|
||||
w, err := os.OpenFile(sslKeylogFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600)
|
||||
if err != nil {
|
||||
fail(err, "Could not open SSLKEYLOGFILE %s", sslKeylogFile)
|
||||
}
|
||||
tlsConf.KeyLogWriter = w
|
||||
}
|
||||
|
||||
creds := credentials.NewTLS(tlsConf)
|
||||
|
||||
// can use either -servername or -authority; but not both
|
||||
if *serverName != "" && *authority != "" {
|
||||
if *serverName == *authority {
|
||||
|
||||
Reference in New Issue
Block a user