diff --git a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts index 21fd81819ffc7..0f1744380a0ca 100644 --- a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts +++ b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.test.ts @@ -1241,6 +1241,39 @@ ssl.test: 123 `); }); + it('should keep ssl fields for es output type', () => { + const policyOutput = transformOutputToFullPolicyOutput( + { + id: 'id123', + hosts: ['http://host.fr'], + is_default: false, + is_default_monitoring: false, + name: 'test output', + type: 'elasticsearch', + ssl: { + certificate: '', + certificate_authorities: [], + }, + }, + undefined, + false + ); + + expect(policyOutput).toMatchInlineSnapshot(` + Object { + "hosts": Array [ + "http://host.fr", + ], + "preset": "balanced", + "ssl": Object { + "certificate": "", + "certificate_authorities": Array [], + }, + "type": "elasticsearch", + } + `); + }); + it('should works with proxy', () => { const policyOutput = transformOutputToFullPolicyOutput( { diff --git a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts index 9cee55f62b1d7..ef1c4c6e170f0 100644 --- a/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts +++ b/x-pack/plugins/fleet/server/services/agent_policies/full_agent_policy.ts @@ -483,7 +483,7 @@ export function transformOutputToFullPolicyOutput( ...(secrets ? { secrets } : {}), ...(ca_trusted_fingerprint ? { 'ssl.ca_trusted_fingerprint': ca_trusted_fingerprint } : {}), }; - if ((output.type === outputType.Kafka || output.type === outputType.Logstash) && ssl) { + if (ssl) { newOutput.ssl = { ...newOutput.ssl, ...ssl,