Skip to content

Commit

Permalink
Backport elastic-agent#1867
Browse files Browse the repository at this point in the history
Backport elastic-agent#1867 that forces the agent use use certificate
verification instead of full verification when connecting to a local
fleet-server instance. This change should resolve fleet-server#3435
which is a change in how certificates are verified when the beats lib in
7.17 is updated in fleet-server.
  • Loading branch information
michel-laterman committed Apr 9, 2024
1 parent d53d1a8 commit a650f1c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ func (c *enrollCmd) writeDelayEnroll(streams *cli.IOStreams) error {
func (c *enrollCmd) fleetServerBootstrap(ctx context.Context, persistentConfig map[string]interface{}) (string, error) {
c.log.Debug("verifying communication with running Elastic Agent daemon")
agentRunning := true
if c.options.FleetServer.InternalPort == 0 {
c.options.FleetServer.InternalPort = defaultFleetServerInternalPort
}
_, err := getDaemonStatus(ctx)
if err != nil {
if !c.options.FleetServer.SpawnAgent {
Expand Down Expand Up @@ -321,6 +324,7 @@ func (c *enrollCmd) fleetServerBootstrap(ctx context.Context, persistentConfig m
if err != nil {
return "", err
}
c.options.FleetServer.InternalPort = fleetConfig.Server.InternalPort

configToStore := map[string]interface{}{
"agent": agentConfig,
Expand Down Expand Up @@ -531,6 +535,9 @@ func (c *enrollCmd) enroll(ctx context.Context, persistentConfig map[string]inte
// use internal URL for future requests
if c.options.InternalURL != "" {
fleetConfig.Client.Host = c.options.InternalURL
// fleet-server will bind the internal listenter to localhost:8221
// InternalURL is localhost:8221, however cert uses $HOSTNAME, so we need to disable hostname verification.
fleetConfig.Client.Transport.TLS.VerificationMode = tlscommon.VerifyCertificate
}
}

Expand Down

0 comments on commit a650f1c

Please sign in to comment.