Only read in TLS certs when the key and cert are present.

pull/385/head
Sean Chittenden 2018-02-02 08:37:23 -08:00
parent f0dc593c2f
commit 6a4303120f
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
1 changed files with 7 additions and 5 deletions

12
conn.go
View File

@ -953,12 +953,14 @@ func configTLS(args configTLSArgs, cc *ConnConfig) error {
return fmt.Errorf(`both "sslcert" and "sslkey" are required`)
}
cert, err := tls.LoadX509KeyPair(sslcert, sslkey)
if err != nil {
return errors.Wrap(err, "unable to read cert")
}
if sslcert != "" && sslkey != "" {
cert, err := tls.LoadX509KeyPair(sslcert, sslkey)
if err != nil {
return errors.Wrap(err, "unable to read cert")
}
cc.TLSConfig.Certificates = []tls.Certificate{cert}
cc.TLSConfig.Certificates = []tls.Certificate{cert}
}
return nil
}