Skip to content

Commit

Permalink
Allow to use TLS with ES basic auth (jaegertracing#1388)
Browse files Browse the repository at this point in the history
* Allow to use TLS with ES basic auth

Signed-off-by: Pavol Loffay <[email protected]>

* Change flag messages

Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay authored and Annanay committed Mar 1, 2019
1 parent 2eaac79 commit 78696af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
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

0 comments on commit 78696af

Please sign in to comment.