Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use TLS with ES basic auth #1388

Merged
merged 2 commits into from
Feb 28, 2019
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
21 changes: 11 additions & 10 deletions pkg/es/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,25 +256,26 @@ func (c *Configuration) getConfigOptions() ([]elastic.ClientOptionFunc, error) {
TLSClientConfig: ctlsConfig,
}
} else {
httpTransport := &http.Transport{}
if c.TLS.CaPath != "" {
ctls := &TLSConfig{CaPath: c.TLS.CaPath}
ca, err := ctls.loadCertificate()
if err != nil {
return nil, err
}
httpTransport.TLSClientConfig = &tls.Config{RootCAs: ca}
}
if c.TokenFilePath != "" {
token, err := loadToken(c.TokenFilePath)
if err != nil {
return nil, err
}
wrapped := &http.Transport{}
if c.TLS.CaPath != "" {
ctls := &TLSConfig{CaPath: c.TLS.CaPath}
ca, err := ctls.loadCertificate()
if err != nil {
return nil, err
}
wrapped.TLSClientConfig = &tls.Config{RootCAs: ca}
}
httpClient.Transport = &tokenAuthTransport{
token: token,
wrapped: wrapped,
wrapped: httpTransport,
}
} else {
httpClient.Transport = httpTransport
options = append(options, elastic.SetBasicAuth(c.Username, c.Password))
}
}
Expand Down
6 changes: 3 additions & 3 deletions plugin/storage/es/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) {
flagSet.String(
nsConfig.namespace+suffixUsername,
nsConfig.Username,
"The username required by ElasticSearch")
"The username required by ElasticSearch. The basic authentication also loads CA if it is specified.")
flagSet.String(
nsConfig.namespace+suffixPassword,
nsConfig.Password,
"The password required by ElasticSearch")
flagSet.String(
nsConfig.namespace+suffixTokenPath,
nsConfig.TokenFilePath,
"Path to a file containing bearer token. This flag also uses CA if it is specified")
"Path to a file containing bearer token. This flag also loads CA if it is specified.")
flagSet.Bool(
nsConfig.namespace+suffixSniffer,
nsConfig.Sniffer,
Expand Down Expand Up @@ -173,7 +173,7 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) {
flagSet.Bool(
nsConfig.namespace+suffixTLS,
nsConfig.TLS.Enabled,
"Enable TLS")
"Enable TLS with client certificates.")
flagSet.String(
nsConfig.namespace+suffixCert,
nsConfig.TLS.CertPath,
Expand Down