# Elastic Agent ca\_trusted\_fingerprint does not working, but the certificate works

**URL:** https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239
**Category:** Elastic Agent
**Created:** [June 29, 2024, 5:19am UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239 "2024-06-29T05:19:17Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [June 29, 2024, 5:19am UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/1 "2024-06-29T05:19:17Z")

</div>

Hello,

I've built a simple docker compose that will spin up a single node cluster with Elasticsearch, Kibana and a Fleet server and I'm facing an issue where the `ca_trusted_fingerprint` is not working as expected.

The compose will create a CA and a certificate using openssl and in a further step it will create a default elasticsearch output in fleet with the sha256 fingerprint of the ca as the value for `ca_trusted_fingerprint`.

The issue is that it even with the `ca_trusted_fingerprint` configured, the Agent on the fleet container cannot connect to the Elasticsearch container and keeps throwing the unknown authority error.

> Error dialing x509: certificate signed by unknown authority

But if I get the certificate and configure in the advanced yml with `ssl.certificate_authorities`, it will work.

For example, considering the CA file as `ca-siem.pem`, I can get the fingerprint with the following command:

```auto
sudo openssl x509 -fingerprint -sha256 -in ca-siem.pem

```

And the result will be something like this:

```auto
sha256 Fingerprint=2F:96:88:4D:A6:20:0B:ED:CA:CE:E9:92:85:99:1E:31:E8:78:75:CD:67:68:4A:82:CD:D3:20:8C:C2:D5:EC:55
-----BEGIN CERTIFICATE-----
MIIDkTCCAnmgAwIBAgIUcElxHmR8/QJQRmpQ1OXMdmQsFbkwDQYJKoZIhvcNAQEL
BQAwWDELMAkGA1UEBhMCQlIxCzAJBgNVBAgMAlJKMRcwFQYDVQQHDA5SSU8g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NjWCPMBgwGttXIAcB7DjnBwcqdhkRfj8
kl+ZnaI=
-----END CERTIFICATE-----

```

The `ca_trusted_fingerprint` would then be configured to use `2F96884DA6200BEDCACEE99285991E31E87875CD67684A82CDD3208CC2D5EC55` as the value.

But this will lead to errors regarding the fingerprint and the unkown authority:

```auto
{"log.level":"info","@timestamp":"2024-06-29T04:56:58.691Z","message":"'ca_trusted_fingerprint' set, looking for matching fingerprints","component":{"binary":"metricbeat","dataset":"elastic_agent.metricbeat","id":"beat/metrics-monitoring","type":"beat/metrics"},"log":{"source":"beat/metrics-monitoring"},"log.origin":{"file.line":179,"file.name":"tlscommon/tls_config.go","function":"github.com/elastic/elastic-agent-libs/transport/tlscommon.trustRootCA"},"service.name":"metricbeat","ecs.version":"1.6.0","log.logger":"tls","ecs.version":"1.6.0"}
{"log.level":"warn","@timestamp":"2024-06-29T04:56:58.691Z","message":"no CA certificate matching the fingerprint","component":{"binary":"metricbeat","dataset":"elastic_agent.metricbeat","id":"beat/metrics-monitoring","type":"beat/metrics"},"log":{"source":"beat/metrics-monitoring"},"log.logger":"tls","log.origin":{"file.line":208,"file.name":"tlscommon/tls_config.go","function":"github.com/elastic/elastic-agent-libs/transport/tlscommon.trustRootCA"},"service.name":"metricbeat","ecs.version":"1.6.0","ecs.version":"1.6.0"}
{"log.level":"error","@timestamp":"2024-06-29T04:56:58.691Z","message":"Error dialing x509: certificate signed by unknown authority","component":{"binary":"metricbeat","dataset":"elastic_agent.metricbeat","id":"beat/metrics-monitoring","type":"beat/metrics"},"log":{"source":"beat/metrics-monitoring"},"log.origin":{"file.line":38,"file.name":"transport/logging.go","function":"github.com/elastic/elastic-agent-libs/transport/httpcommon.(*HTTPTransportSettings).RoundTripper.LoggingDialer.func2"},"service.name":"metricbeat","address":"elasticsearch:9200","log.logger":"esclientleg","network":"tcp","ecs.version":"1.6.0","ecs.version":"1.6.0"}

```

But if I use the certificate in the advanced yaml configuration it will work.

```auto
ssl.certificate_authorities:
  - |
    -----BEGIN CERTIFICATE-----
    MIIDkTCCAnmgAwIBAgIUcElxHmR8/QJQRmpQ1OXMdmQsFbkwDQYJKoZIhvcNAQEL
    BQAwWDELMAkGA1UEBhMCQlIxCzAJBgNVBAgMAlJKMRcwFQYDVQQHDA5SSU8gREUg
    SkFORUlSTzEUMBIGA1UECgwLU0lFTSBET0NLRVIxDTALBgNVBAsMBFNJRU0wHhcN
    MjQwNjI5MDQ0NjAyWhcNMjkwNzAzMDQ0NjAyWjBYMQswCQYDVQQGEwJCUjELMAkG
    A1UECAwCUkoxFzAVBgNVBAcMDlJJTyBERSBKQU5FSVJPMRQwEgYDVQQKDAtTSUVN
    IERPQ0tFUjENMAsGA1UECwwEU0lFTTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
    AQoCggEBANIyUorRCtZRcH2JMEbT3xInlCakNHu5fUCigx3IA5IgegpJOgXghO2B
    25QQ21FJXsvLBEklde+f9BC2AwfST2g8fvqDjCHvnX3MygibfWDXKAvrkTSDqGPR
    z07i1DQEyTkkJcuud8d7fuUNZ8LS40n+IPdRBFI0qeHFNoYudIf9e09aqICRO/wZ
    EkjR4uV2UjoBXYHNLsn8uDqCd1Zx70deQDuXMYP+9jJ0oWaXfKlt92qGg6TGsthF
    9rMX0b2VM22Tw7YvVhYHoH0Pk6f5fphFF0LeSXQEITEP9yCuHHTNGhf5lpkzg5UV
    HgKbTx24EmFm48zGeEuhKMjtUfu+tdUCAwEAAaNTMFEwHQYDVR0OBBYEFKSw10ms
    wAMXgIlrD2Ns1BjVB2LeMB8GA1UdIwQYMBaAFKSw10mswAMXgIlrD2Ns1BjVB2Le
    MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAOwTRBloKxr8EGG
    Mge2pMpxb5pK6zUwsFe4nhJq/5gxxpNoEALvLRMWA7fGF9UNB6pHEmZzSRyJeDnC
    L3sYwgwmcExqfKkDWlDCuvnVcFi3drgDUp86iDuaUs7LrGZYBlbJdk4SaVuSfmd5
    mfgrmoqzqeHwZnnJsft6CVlTr2J76EC5tiWsiAvlTPPYq3swugckXLI4IhGV9HHy
    cbaA9EHZ0qFi6rkUfGX8NuByPxtUbH6clmxT1LzvQzx9evaMUE+ZIaN2I9n48yFU
    0DGCk/bjNG3PLnD/iZwvE29RSMvTW1OwNjWCPMBgwGttXIAcB7DjnBwcqdhkRfj8
    kl+ZnaI=
    -----END CERTIFICATE-----

```

The certificate works, but the fingerprint does not work, what am I missing?

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [June 29, 2024, 3:52pm UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/2 "2024-06-29T15:52:17Z")

</div>

Hi @leandrojmp !!

Can you share your compose?

Perhaps I can take a look later today

Quicktest would be does the fingerprint work with a beat?

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [June 29, 2024, 5:44pm UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/3 "2024-06-29T17:44:41Z")

</div>

> [@stephenb](#):
>
> Can you share your compose?

Sure, it is in this repository: [GitHub - leandrojmp/docker-elastic](https://github.com/leandrojmp/docker-elastic)

The README is in portuguese, but you just need to create the `.env`.

It will then create the certificates, configure the kibana user and fleet output.

The only issue I'm having is that the fingerprint does not work, but the certificate works.

It was based on this another project [GitHub - peasead/elastic-container: Stand up a simple Elastic container with Kibana, Fleet, and the Detection Engine](https://github.com/peasead/elastic-container), but way simpler.

The main difference Is that I'm creating my CA and certificates using `openssl`, not `elasticsearch-certutil`, and to make it even more simpler I'm using the same certificate for elasticsearch, kibana and fleet.

> [@stephenb](#):
>
> Quicktest would be does the fingerprint work with a beat?

Didn't test this, but will try something like this later.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [June 29, 2024, 6:15pm UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/4 "2024-06-29T18:15:00Z")

</div>

@leandrojmp

So what is in the repo is the working version without using the fingerprint confirm?

Can you share the version where you tried to use the fingerprint?

One quick look ... I don't see any [of these under fleet](https://www.elastic.co/guide/en/fleet/8.14/elastic-agent-cmd-options.html#elastic-agent-install-command)  
I would expect to see 1st or 2nd or 3 and 4  
I believe These are what are forwarded down to the agents (and used with the outputs) I would need to take a closer look...

```auto
[--fleet-server-es-ca <string>]
[--fleet-server-es-ca-trusted-fingerprint <string>] 
^^^This is the one you are trying to set? 
[--fleet-server-es-cert <string>]
[--fleet-server-es-cert-key <string>]

```

> `--fleet-server-es-ca-trusted-fingerprint <string>`  
> The SHA-256 fingerprint (hash) of the certificate authority used to self-sign Elasticsearch certificates. This fingerprint will be used to verify self-signed certificates presented by Fleet Server and any inputs started by Elastic Agent for communication. This flag is required when using self-signed certificates with Elasticsearch.

When I get a chance I will look

If you generate the command from Kibana you will see (yes I know you need more ... just double checking)

```auto
sudo ./elastic-agent install \
  --fleet-server-es=https://192.168.2.107:9200 \
  --fleet-server-service-token=AAEAAWVsYXN0aWMvZmxlZXQtc2VydmVyL3Rva2VuLTE3MTk2ODUxMjIxNjI6SWt1c1NFdFRUWC1DNnB2T0xOd0w0UQ \
  --fleet-server-policy=fleet-server-policy \
  --fleet-server-es-ca-trusted-fingerprint=1f5fd789732ce83a08778ca577502769f8159beecc1a8d5f1edc95422321e528 \
  --fleet-server-port=8220

```

BTW I did a quick metricbeat test using the trusted fingerprint and it worked... using mine I will try with yours...

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [June 29, 2024, 8:01pm UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/5 "2024-06-29T20:01:27Z")

</div>

> [@stephenb](#):
>
> So what is in the repo is the working version without using the fingerprint confirm?

No, there is no working version using the fingerprint, this is what I'm trying to troubleshoot.

The docker compose in the repository will perform the following steps:

- Spin-up a one-time container using the ubuntu image to create a custom CA and a certificate, this certificate will be used by the elasticsearch, kibana and fleet containers.  
The certificates is stored on a persistent path that is shared with the other containers.

- After that, a Elasticsearch single-node container will be started and use the certificate generate in the previous step for both the transport and http endpoints.

- When the Elasticsearch container is healthy, a one-time container will run to setup the password for the `kibana_system` user as we cannot use the internal `elastic` user anymore.

- The next step is to spin-up a Kibana container and when it is healthy another one-time container will be executed to setup two fleet settings, the fleet host and the default output.

- This `setup_fleet` container is required to avoid the need to manually create a fleet host and to change the default output to point to the elasticsearch container, the default value is `https://localhost:9200` which of course will not work, it is in this step that the `ca_trusted_fingerprint` is used.

- The last step is to start a container running the Elastic Agent with the Fleet Server integration.

The only issue I'm facing is that the container running the Fleet Server cannot send data to the cluster because it is not recognizing the `ca_trusted_fingerprint`.

After running the compose, this is how the output configuration looks like:

 ![Screenshot from 2024-06-29 16-46-04](https://us1.discourse-cdn.com/elastic/original/3X/6/c/6cd5f0a28e22477d6426d09938d7b395a2532119.jpeg)

If I use `openssl` to check the generate certificate, I will have this:

> sha256 Fingerprint= **8F:08:33:C6:AC:54:B9:8C:95:67:AC:57:62:14:1A:05:11:EE:63:30:B0:5E:3D:E7:7E:06:6E:2D:38:E6:FE:E4**  
> -----BEGIN CERTIFICATE-----  
> MIIDlzCCAn+gAwIBAgIUKnZdiBZHMD7lz90tGQBgnbG8HQEwDQYJKoZIhvcNAQEL  
> BQAwWzELMAkGA1UEBhMCQlIxCzAJBgNVBAgMA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1oW3NnrI7MigJSFNAuDlraTY8cyp7mLJLeJUNFx4M+HuUQaRvyUNK  
> DxCFgP3bW6MrljJj3rMNaUlKq7HoSlYv73NdMoRPz62mpp8D7eLyhq8+r+wr46Tq  
> 6SokdUdWcoNEIT0=  
> -----END CERTIFICATE-----

As you can see, the fingerprint comes from the certificate, but I got these errors messages in the fleet container:

> 'ca\_trusted\_fingerprint' set, looking for matching fingerprints"

Followed by

> no CA certificate matching the fingerprint

But now, if I change the output in the fleet settings to this:

 ![Screenshot from 2024-06-29 16-53-10](https://us1.discourse-cdn.com/elastic/original/3X/0/0/00d7bf71d6cf7fd475cd6b8fe9f8bc400dc40cbc.png)

Everything will work fine and I will get the logs inside the cluster, which I can confirm looking at the container logs:

> Connection to backoff(elasticsearch([https://elasticsearch:9200](https://elasticsearch:9200))) established

So, to resume, I have a CA certificate, the agent cannot send data if I use just the fingerprint of this certificate, but it can send data if I use the certificate in the advanced yaml configuration.

Of course I've could change my docker-compose to set the entire certificate in the `setup_fleet` step, but I'm trying to understand what is the issue here.

I've tested with both 8.13.4 and 8.14.1, same behaviour in both.

> [@stephenb](#):
>
> One quick look ... I don't see any [of these under fleet](https://www.elastic.co/guide/en/fleet/8.14/elastic-agent-cmd-options.html#elastic-agent-install-command)  
> I would expect to see 1st or 2nd or 3 and 4  
> I believe These are what are forwarded down to the agents (and used with the outputs)

No, these are used when enrolling the agent, I have no issues enrolling the agent that will work as the Fleet Server, I'm using the ca file in the enroll process.

Also, the default output created in Fleet does not use none of these settings, it creates a dummy `default` output pointing to `https://localhost:9200` that you have to manually change.

What I'm doing is using the Fleet API to change this during the setup process, and to make it easier I'm trying to use the fingerprint of the CA.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [June 29, 2024, 8:37pm UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/6 "2024-06-29T20:37:14Z")

</div>

Ok I am caught all the way up....  
(I got hung up along the way on the `kibana_user.exist` you have to manually clean that up)

I am in the same state as you ... let me poke... weird...

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [June 29, 2024, 9:05pm UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/7 "2024-06-29T21:05:14Z")

</div>

@leandrojmp Found something ... and you are more of a cert expert than I.

So setup with your exact compose...

Then I put the CA fingerprint in metricbeat and test the output

Same error BUT if I set this with my other script that uses all the normal gen certs with our tool it works... (not saying you have to, but there must be some difference)

So seems to me ... something is wrong with a cert chain or the fingerprint  
(or something wrong with the way we validate etc)

Last line seems to indicate  
` ERROR x509: “SIEM” certificate is not standards compliant`

If you look at the 2 last logs... same as you are getting with the fleet...

```auto
./metricbeat -e test output
...
elasticsearch: https://localhost:9200...
  parse url... OK
  connection...
    parse host... OK
    dns lookup... OK
    addresses: ::1, 127.0.0.1
    dial up... OK
  TLS...
    security: server's certificate chain verification is enabled
{"log.level":"info","@timestamp":"2024-06-29T14:02:28.165-0700","log.logger":"tls","log.origin":{"function":"github.com/elastic/elastic-agent-libs/transport/tlscommon.trustRootCA","file.name":"tlscommon/tls_config.go","file.line":179},"message":"'ca_trusted_fingerprint' set, looking for matching fingerprints","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"warn","@timestamp":"2024-06-29T14:02:28.165-0700","log.logger":"tls","log.origin":{"function":"github.com/elastic/elastic-agent-libs/transport/tlscommon.trustRootCA","file.name":"tlscommon/tls_config.go","file.line":208},"message":"no CA certificate matching the fingerprint","service.name":"metricbeat","ecs.version":"1.6.0"}
    handshake... ERROR x509: “SIEM” certificate is not standards compliant
hyperion:metricbeat-8.14.1-darwin-x86_64 sbrown$

```

Looks like the code [here](https://github.com/elastic/elastic-agent-libs/blob/3dbdeaecd06e18ab9661e7f8038ed67e6ab024ee/transport/tlscommon/tls_config.go#L177)

And here is what it looks like when it matches this is just an elasticsearch doing the default setup.

```auto
elasticsearch: https://localhost:9200...
  parse url... OK
  connection...
    parse host... OK
    dns lookup... OK
    addresses: ::1, 127.0.0.1
    dial up... OK
  TLS...
    security: server's certificate chain verification is enabled
{"log.level":"info","@timestamp":"2024-06-29T14:12:16.403-0700","log.logger":"tls","log.origin":{"function":"github.com/elastic/elastic-agent-libs/transport/tlscommon.trustRootCA","file.name":"tlscommon/tls_config.go","file.line":179},"message":"'ca_trusted_fingerprint' set, looking for matching fingerprints","service.name":"metricbeat","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2024-06-29T14:12:16.403-0700","log.logger":"tls","log.origin":{"function":"github.com/elastic/elastic-agent-libs/transport/tlscommon.trustRootCA","file.name":"tlscommon/tls_config.go","file.line":199},"message":"CA certificate matching 'ca_trusted_fingerprint' found, adding it to 'certificate_authorities'","service.name":"metricbeat","ecs.version":"1.6.0"}
    handshake... OK
    TLS version: TLSv1.3
    dial up... OK

```

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [June 29, 2024, 9:24pm UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/8 "2024-06-29T21:24:18Z")

</div>

> [@stephenb](#):
>
> ERROR x509: “SIEM” certificate is not standards compliant

Oh Thanks!

This doesn't show up in the elastic agent logs, but this gives some direction on what to troubleshoot.

Maybe the way I'm creating the CA and certificates with `openssl` is not the correct way, I will look into it.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [June 29, 2024, 9:27pm UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/9 "2024-06-29T21:27:35Z")

</div>

Hard to debug... argh!

So when I get stuck like this...

I use Elastic tar.gz and metricbeat

Generate the certs etc... turn logging way up... once you get that working go back to docker etc... just a thought might speed up the dev / test cycle.

One thing I notice you are generating a CA with a .pem and a .key ... and when I see the default way the CA has no key as far as I can tell...

But also makes me wonder in the siem.pem (the SSL cert) is missing the "fullchain"

I notice that my default SSL cert is significantly longer than yours.

UPDATE  
Looked some more... Think you need your `siem.pem` to be full chain  
ca + cert when I decode mine that works... that is what is there...

Which kinda makes sense ... because you are asking the fingerprint (which is of the CA) to match a cert coming across the wire...

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [June 30, 2024, 12:53am UTC](https://discuss.elastic.co/t/elastic-agent-ca-trusted-fingerprint-does-not-working-but-the-certificate-works/362239/10 "2024-06-30T00:53:04Z")

</div>

> [@stephenb](#):
>
> Looked some more... Think you need your `siem.pem` to be full chain  
> ca + cert when I decode mine that works... that is what is there...

Yeah, this was the issue indeed.

I've added the following line in my container that setup the certs:

> cat ca-siem.pem siem.pem \> siem.chain.pem

Then Elasticsearch stopped working with a SSL error, like this:

> Caused by: org.elasticsearch.ElasticsearchException: failed to initialize SSL KeyManagerFactory

Inverting the order in the chain certificate solved it, so I first need to add the server certificate and after that the ca certificate.

> cat siem.pem ca-siem.pem \> siem.chain.pem

And have this in the settings:

```auto
      - xpack.security.http.ssl.key=certs/siem-key.pem
      - xpack.security.http.ssl.certificate=certs/siem.chain.pem

```

After that everything worked as expected and I got this message in the agent logs:

> CA certificate matching 'ca\_trusted\_fingerprint' found, adding it to 'certificate\_authorities'

I think that I understood how this work now.

The Elasticsearch server will present the agent with the certificate, and then the agent will try to match the `ca_trusted_fingerprint` with one of the certificates, if it can match, it will then add it to the `ssl.certificate_authorities` setting, this also explains why it works when adding directly to the `ssl.certificate_authorities`.

So, for this to work, you need to have the full chain, or at least the server + the ca certificates.

In the end the main issue was a small gap of knowledge on how SSL works in this case 😅 🤦‍♂️

Thanks!
