Skip to content

Commit

Permalink
Set RootCAs to nil in default case.
Browse files Browse the repository at this point in the history
Currently we create an empty CA store, which is not a very useful
default.

The documentation for [cryto/tls#Config](https://godoc.org/crypto/tls#Config) says:

> If RootCAs is nil, TLS uses the host's root CA set.

I want to use this with confluent cloud, that is using certificates
signed by a proper root CA. So loading the system CAs makes everything
work properly just by enabling tls `--tls.enabled`
  • Loading branch information
errm committed Jan 9, 2023
1 parent d520b86 commit 3852615
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ func NewExporter(opts kafkaOpts, topicFilter string, groupFilter string) (*Expor

config.Net.TLS.Config = &tls.Config{
ServerName: opts.tlsServerName,
RootCAs: x509.NewCertPool(),
InsecureSkipVerify: opts.tlsInsecureSkipTLSVerify,
}

if opts.tlsCAFile != "" {
if ca, err := ioutil.ReadFile(opts.tlsCAFile); err == nil {
config.Net.TLS.Config.RootCAs = x509.NewCertPool()
config.Net.TLS.Config.RootCAs.AppendCertsFromPEM(ca)
} else {
return nil, err
Expand Down

0 comments on commit 3852615

Please sign in to comment.