Skip to content

Commit

Permalink
Fix issue where --insecure didn't propogate to Fleet Server ES connec…
Browse files Browse the repository at this point in the history
…tion (elastic#27969) (elastic#27978)

* Fix issue where --insecure didn't propogate to Fleet Server ES connection.

* Add changelog.

(cherry picked from commit 576be96)

Co-authored-by: Blake Rouse <blake.rouse@elastic.co>
  • Loading branch information
mergify[bot] and blakerouse authored Sep 16, 2021
1 parent 4205e94 commit cb4ecaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
- Add validation for certificate flags to ensure they are absolute paths. {pull}27779[27779]
- Migrate state on upgrade {pull}27825[27825]
- Snapshot artifact lookup will use agent.download proxy settings. {issue}27903[27903] {pull}27904[27904]
- Fix issue where --insecure didn't propogate to Fleet Server ES connection. {pull}27969[27969]

==== New features

Expand Down
10 changes: 9 additions & 1 deletion x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ func (c *enrollCmd) fleetServerBootstrap(ctx context.Context) (string, error) {
c.options.FleetServer.ConnStr, c.options.FleetServer.ServiceToken,
c.options.FleetServer.PolicyID,
c.options.FleetServer.Host, c.options.FleetServer.Port,
c.options.Insecure,
c.options.FleetServer.Cert, c.options.FleetServer.CertKey, c.options.FleetServer.ElasticsearchCA,
c.options.FleetServer.Headers,
c.options.FleetServer.ProxyURL,
Expand Down Expand Up @@ -460,6 +461,7 @@ func (c *enrollCmd) enroll(ctx context.Context, persistentConfig map[string]inte
c.options.FleetServer.ConnStr, c.options.FleetServer.ServiceToken,
c.options.FleetServer.PolicyID,
c.options.FleetServer.Host, c.options.FleetServer.Port,
c.options.Insecure,
c.options.FleetServer.Cert, c.options.FleetServer.CertKey, c.options.FleetServer.ElasticsearchCA,
c.options.FleetServer.Headers,
c.options.FleetServer.ProxyURL, c.options.FleetServer.ProxyDisabled, c.options.FleetServer.ProxyHeaders)
Expand Down Expand Up @@ -759,7 +761,7 @@ func storeAgentInfo(s saver, reader io.Reader) error {

func createFleetServerBootstrapConfig(
connStr, serviceToken, policyID, host string,
port uint16,
port uint16, insecure bool,
cert, key, esCA string,
headers map[string]string,
proxyURL string,
Expand Down Expand Up @@ -817,6 +819,12 @@ func createFleetServerBootstrapConfig(
},
}
}
if insecure {
if cfg.Server.TLS == nil {
cfg.Server.TLS = &tlscommon.Config{}
}
cfg.Server.TLS.VerificationMode = tlscommon.VerifyNone
}

if localFleetServer {
cfg.Client.Transport.Proxy.Disable = true
Expand Down

0 comments on commit cb4ecaa

Please sign in to comment.