Merge pull request #706 from Kilowhisky/SSL_NO_AUTH

Add support for 'none' authentication for kafka while still allowing SSL
This commit is contained in:
Josh Baker 2023-11-20 11:25:54 -07:00 committed by GitHub
commit 4c34a534d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -140,6 +140,24 @@ func (conn *KafkaConn) Send(msg string) error {
} }
cfg.Net.TLS.Config = &tlsConfig cfg.Net.TLS.Config = &tlsConfig
case "none":
// This path allows to either provide a custom ca certificate
// or, because RootCAs is nil, is using the hosts ca set
// to verify the server certificate
if conn.ep.Kafka.SSL {
tlsConfig := tls.Config{}
if conn.ep.Kafka.CACertFile != "" {
caCertPool, err := loadRootTLSCert(conn.ep.Kafka.CACertFile)
if err != nil {
return err
}
tlsConfig.RootCAs = &caCertPool
}
cfg.Net.TLS.Enable = true
cfg.Net.TLS.Config = &tlsConfig
}
} }
c, err := sarama.NewSyncProducer([]string{uri}, cfg) c, err := sarama.NewSyncProducer([]string{uri}, cfg)