Skip to content

Commit

Permalink
Do not require a client certificate in SslOptions
Browse files Browse the repository at this point in the history
The Certificates field in a tls.Config can be empty for a client;
this allows that configuration to work for SslOptions.
  • Loading branch information
Maciek Sakrejda committed Jun 12, 2015
1 parent bac7de2 commit 8ab3de6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions connectionpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,17 @@ func setupTLSConfig(sslOpts *SslOptions) (*tls.Config, error) {
}
}

mycert, err := tls.LoadX509KeyPair(sslOpts.CertPath, sslOpts.KeyPath)
if err != nil {
return nil, fmt.Errorf("connectionpool: unable to load X509 key pair: %v", err)
mycerts := make([]tls.Certificate, 0)
if sslOpts.CertPath != "" || sslOpts.KeyPath != "" {
mycert, err := tls.LoadX509KeyPair(sslOpts.CertPath, sslOpts.KeyPath)
if err != nil {
return nil, fmt.Errorf("connectionpool: unable to load X509 key pair: %v", err)
}
mycerts = append(mycerts, mycert)
}

config := &tls.Config{
Certificates: []tls.Certificate{mycert},
Certificates: mycerts,
RootCAs: certPool,
}

Expand Down

0 comments on commit 8ab3de6

Please sign in to comment.