Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ type ConsulConfig struct {
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
Token string `mapstructure:"token"`
// CACert is the path to the CA certificate used to verify the Consul
// server certificate when connecting over HTTPS (production only).
CACert string `mapstructure:"ca_cert"`
}

type NATsConfig struct {
Expand Down
8 changes: 8 additions & 0 deletions pkg/infra/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ func GetConsulClient(environment string) *api.Client {
Password: password,
}
}

// Trust a custom CA for the Consul HTTPS endpoint. When unset, the
// client falls back to CONSUL_CACERT/CONSUL_CAPATH env vars and then
// the system trust store.
if caCert := viper.GetString("consul.ca_cert"); caCert != "" {
config.TLSConfig.CAFile = caCert
}
}

config.Address = viper.GetString("consul.address")
Expand All @@ -44,6 +51,7 @@ func GetConsulClient(environment string) *api.Client {
"wait_time", config.WaitTime,
"token_length", tokenLength,
"http_auth", config.HttpAuth,
"ca_cert", config.TLSConfig.CAFile,
)

// Ping the Consul server to verify connectivity
Expand Down
Loading