Skip to content

Commit

Permalink
Allow TLS connection without client authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrown14 committed Feb 5, 2020
1 parent dd3750f commit 49f4948
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions cmd/kaf/kaf.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,24 @@ func getConfig() (saramaConfig *sarama.Config) {
tlsConfig.RootCAs = caCertPool
}

clientCert, err := ioutil.ReadFile(cluster.TLS.Clientfile)
if err != nil {
errorExit("Unable to read Clientfile :%v\n", err)
}
clientKey, err := ioutil.ReadFile(cluster.TLS.Clientkeyfile)
if err != nil {
errorExit("Unable to read Clientkeyfile :%v\n", err)
}
if cluster.TLS.Clientfile != "" && cluster.TLS.Clientkeyfile != "" {
clientCert, err := ioutil.ReadFile(cluster.TLS.Clientfile)
if err != nil {
errorExit("Unable to read Clientfile :%v\n", err)
}
clientKey, err := ioutil.ReadFile(cluster.TLS.Clientkeyfile)
if err != nil {
errorExit("Unable to read Clientkeyfile :%v\n", err)
}

cert, err := tls.X509KeyPair([]byte(clientCert), []byte(clientKey))
if err != nil {
errorExit("Unable to creatre KeyPair: %v\n", err)
}
tlsConfig.Certificates = []tls.Certificate{cert}
cert, err := tls.X509KeyPair([]byte(clientCert), []byte(clientKey))
if err != nil {
errorExit("Unable to creatre KeyPair: %v\n", err)
}
tlsConfig.Certificates = []tls.Certificate{cert}

tlsConfig.BuildNameToCertificate()
tlsConfig.BuildNameToCertificate()
}
saramaConfig.Net.TLS.Config = tlsConfig
}
if cluster.SecurityProtocol == "SASL_SSL" {
Expand Down

0 comments on commit 49f4948

Please sign in to comment.