Move SSLKEYLOGFILE logic to caller (main)
This commit is contained in:
parent
e6c26914d4
commit
afb789f147
|
|
@ -408,12 +408,21 @@ func main() {
|
||||||
}
|
}
|
||||||
var creds credentials.TransportCredentials
|
var creds credentials.TransportCredentials
|
||||||
if !*plaintext {
|
if !*plaintext {
|
||||||
var err error
|
tlsConf, err := grpcurl.ClientTLSConfig(*insecure, *cacert, *cert, *key)
|
||||||
creds, err = grpcurl.ClientTransportCredentials(*insecure, *cacert, *cert, *key)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail(err, "Failed to configure transport credentials")
|
fail(err, "Failed to configure TLS config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if os.Getenv("SSLKEYLOGFILE") != "" {
|
||||||
|
w, err := os.OpenFile(os.Getenv("SSLKEYLOGFILE"), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600)
|
||||||
|
if err != nil {
|
||||||
|
fail(err, "Could not open SSLKEYLOGFILE: %v")
|
||||||
|
}
|
||||||
|
tlsConf.KeyLogWriter = w
|
||||||
|
}
|
||||||
|
|
||||||
|
creds := credentials.NewTLS(tlsConf)
|
||||||
|
|
||||||
// can use either -servername or -authority; but not both
|
// can use either -servername or -authority; but not both
|
||||||
if *serverName != "" && *authority != "" {
|
if *serverName != "" && *authority != "" {
|
||||||
if *serverName == *authority {
|
if *serverName == *authority {
|
||||||
|
|
|
||||||
|
|
@ -554,14 +554,6 @@ func ClientTLSConfig(insecureSkipVerify bool, cacertFile, clientCertFile, client
|
||||||
tlsConf.RootCAs = certPool
|
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 &tlsConf, nil
|
return &tlsConf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue