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

Clarification in docs #2038

Closed
nadilas opened this issue Jan 25, 2020 · 4 comments
Closed

Clarification in docs #2038

nadilas opened this issue Jan 25, 2020 · 4 comments

Comments

@nadilas
Copy link

nadilas commented Jan 25, 2020

Hi everyone,

This line cost me 1 day 😄 ...

if c.TLS.Enabled {

Maybe you could update to docs to be more specific in saying --es.tls ignores --es.tls.ca? Or is it just me who got this wrong? 😊

@ghost ghost added the needs-triage label Jan 25, 2020
@nadilas nadilas changed the title Rename flag or add code Clarification in docs Jan 25, 2020
@yurishkuro
Copy link
Member

It should not ignore CA, what makes you think it does?

Meanwhile, this code will change with #1838

@nadilas
Copy link
Author

nadilas commented Jan 26, 2020

@yurishkuro well, when setting —es.tls I don’t see this line in that if path of the code:

if c.TLS.CaPath != "" {

But that’s only after I always had a “no such file or directory” - yes without a file path - error on startup. Removing the —es.tls flag, leaving behind the —es.tls.ca flag fixed the issue. So I checked the code and then came to the conclusion above. Although I didn’t check c.TLS.createTLSConfig() itself.

@jpkrohling
Copy link
Contributor

The code does look strange and I think it could have a few comments, but when the CA path is set, both code branches will attempt to read the file.

if c.TLS.CaPath != "" {
ctls := &TLSConfig{CaPath: c.TLS.CaPath}
ca, err := ctls.loadCertificate()
if err != nil {
return nil, err
}
httpTransport.TLSClientConfig.RootCAs = ca
}

and

func (tlsConfig *TLSConfig) createTLSConfig() (*tls.Config, error) {
rootCerts, err := tlsConfig.loadCertificate()
if err != nil {
return nil, err
}
clientPrivateKey, err := tlsConfig.loadPrivateKey()
if err != nil {
return nil, err
}
// #nosec
return &tls.Config{
RootCAs: rootCerts,
Certificates: []tls.Certificate{*clientPrivateKey},
InsecureSkipVerify: tlsConfig.SkipHostVerify,
}, nil
}

@nadilas
Copy link
Author

nadilas commented Jan 27, 2020

@jpkrohling got it. It does make sense, although the createTLSConfig is actually a createTLSConfigWithClientCertificate implementation.

if c.TLS.CaPath != "" {
ctls := &TLSConfig{CaPath: c.TLS.CaPath}
ca, err := ctls.loadCertificate()
if err != nil {
return nil, err
}
httpTransport.TLSClientConfig.RootCAs = ca
}

Then my issue was definitely not having CertPath and KeyPath set as I was using password authentication. Sorry for the misinterpretation.

@nadilas nadilas closed this as completed Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants