Refactor NATS ssl config
This commit is contained in:
parent
2fe427b3b3
commit
8dd2a8527a
|
@ -21,9 +21,12 @@ type NATS struct {
|
||||||
Subject string
|
Subject string
|
||||||
|
|
||||||
// Path to CA file
|
// Path to CA file
|
||||||
CAFile string `toml:"tls_ca"`
|
SSLCA string `toml:"ssl_ca"`
|
||||||
|
// Path to host cert file
|
||||||
// Skip SSL verification
|
SSLCert string `toml:"ssl_cert"`
|
||||||
|
// Path to cert key file
|
||||||
|
SSLKey string `toml:"ssl_key"`
|
||||||
|
// Use SSL but skip chain & host verification
|
||||||
InsecureSkipVerify bool
|
InsecureSkipVerify bool
|
||||||
|
|
||||||
conn *nats_client.Conn
|
conn *nats_client.Conn
|
||||||
|
@ -38,10 +41,12 @@ var sampleConfig = `
|
||||||
# password = ""
|
# password = ""
|
||||||
## NATS subject for producer messages
|
## NATS subject for producer messages
|
||||||
subject = "telegraf"
|
subject = "telegraf"
|
||||||
## Optional TLS Config
|
|
||||||
## CA certificate used to self-sign NATS server(s) TLS certificate(s)
|
## Optional SSL Config
|
||||||
# tls_ca = "/etc/telegraf/ca.pem"
|
# ssl_ca = "/etc/telegraf/ca.pem"
|
||||||
## Use TLS but skip chain & host verification
|
# ssl_cert = "/etc/telegraf/cert.pem"
|
||||||
|
# ssl_key = "/etc/telegraf/key.pem"
|
||||||
|
## Use SSL but skip chain & host verification
|
||||||
# insecure_skip_verify = false
|
# insecure_skip_verify = false
|
||||||
|
|
||||||
## Data format to output.
|
## Data format to output.
|
||||||
|
@ -65,9 +70,8 @@ func (n *NATS) Connect() error {
|
||||||
opts.Password = n.Password
|
opts.Password = n.Password
|
||||||
}
|
}
|
||||||
|
|
||||||
// is TLS enabled?
|
|
||||||
tlsConfig, err := internal.GetTLSConfig(
|
tlsConfig, err := internal.GetTLSConfig(
|
||||||
"", "", n.CAFile, n.InsecureSkipVerify)
|
n.SSLCert, n.SSLKey, n.SSLCA, n.InsecureSkipVerify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue