diff --git a/x-pack/elastic-agent/CHANGELOG.next.asciidoc b/x-pack/elastic-agent/CHANGELOG.next.asciidoc index 308553a2c06a..202374a85ca0 100644 --- a/x-pack/elastic-agent/CHANGELOG.next.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.next.asciidoc @@ -46,6 +46,7 @@ - Verify communication to Kibana before updating Fleet client. {pull}24489[24489] - Fix nil pointer when null is generated as list item. {issue}23734[23734] - Add support for filestream input. {pull}24820[24820] +- Add check for URL set when cert and cert key. {pull}24904[24904] ==== New features diff --git a/x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go b/x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go index 9760ad021c5e..2f9f98b59751 100644 --- a/x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go +++ b/x-pack/elastic-agent/pkg/agent/cmd/enroll_cmd.go @@ -296,6 +296,10 @@ func (c *enrollCmd) prepareFleetTLS() error { c.options.URL = fmt.Sprintf("https://%s:%d", hostname, port) c.options.CAs = []string{string(ca.Crt())} } + // running with custom Cert and CertKey; URL is required to be set + if c.options.URL == "" { + return errors.New("url is required when a certificate is provided") + } return nil }