Elasticsearch sink: Failed to make HTTP(S) request: error trying to connect: the handshake failed
Vector Version
0.12.2
Vector Configuration File
[sinks.es_out]
# General
type = "elasticsearch" # required
inputs = ["temperature_transformer"] # required
compression = "none" # optional, default
endpoint = "https://elasticsearch-master:9200" # required
index = "sensordata-%Y.%m" # optional, default
#pipeline = "pipeline-name" # optional, no default
auth.user = "${ELASTICSEARCH_USERNAME}"
auth.password = "${ELASTICSEARCH_PASSWORD}"
auth.strategy = "basic"
tls.crt_file = "/usr/share/certs/elastic-certificates.p12"
tls.key_file = "/usr/share/certs/elastic-certificates.p12"
tls.ca_file = "/usr/share/certs/elastic-ca.crt"
tls.verify_hostname = false
# Healthcheck
#healthcheck.enabled = true # optional, default
Error
Mar 31 15:46:05.284 ERROR vector::topology::builder: msg="Healthcheck: Failed Reason." error=Failed to make HTTP(S) request: error trying to connect: the handshake failed: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1913:: self signed certificate in certificate chain component_kind="sink" component_type="elasticsearch" component_name="es_out"
Expected Behavior
I have set up ES x-pack security with self-signed certificates. A few days ago this just worked fine. I had to set up the cluster from scratch, using the same approach and certificates. And suddenly it doesn't work anymore?!
Actual Behavior
The above mentioned error is thrown and communication with ES fails (not only the health check but subsequent calls also).
Example Data
N/A
Additional Context
N/A
References
N/A
Alright, I added tls.verify_certificate = false which seems to do the trick. I'm pretty sure that I haven't used this before, though. Very strange!
Hi @rawbertp . This would seem to indicate that the certificate Elasticsearch is serving is not trusted based based on the CA file you provided Vector. Can you try openssl s_client -connect elasticsearch-master:9200 -CAfile /usr/share/certs/elastic-ca.crt to test?
Hi @jszwedko - this is the response:
root@vector-6dfdb6677c-wtbtl:/# openssl s_client -connect elasticsearch-master:9200 -CAfile /usr/share/certs/elastic-ca.crt
CONNECTED(00000003)
Can't use SSL_get_servername
depth=1 CN = Elastic Certificate Tool Autogenerated CA
verify error:num=19:self signed certificate in certificate chain
verify return:1
depth=1 CN = Elastic Certificate Tool Autogenerated CA
verify return:1
depth=0 CN = elasticsearch-master
verify return:1
---
Certificate chain
0 s:CN = elasticsearch-master
i:CN = Elastic Certificate Tool Autogenerated CA
1 s:CN = Elastic Certificate Tool Autogenerated CA
i:CN = Elastic Certificate Tool Autogenerated CA
---
Server certificate
-----BEGIN CERTIFICATE-----
<snip>
-----END CERTIFICATE-----
subject=CN = elasticsearch-master
issuer=CN = Elastic Certificate Tool Autogenerated CA
---
No client certificate CA names sent
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 2234 bytes and written 363 bytes
Verification error: self signed certificate in certificate chain
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 19 (self signed certificate in certificate chain)
---
---
Post-Handshake New Session Ticket arrived:
SSL-Session:
Protocol : TLSv1.3
Cipher : TLS_AES_256_GCM_SHA384
Session-ID: 9D5E02D82D50911D639762D7BB005AF7BD0D50AB913E243D2BA9ED9CEBB8AC75
Session-ID-ctx:
Resumption PSK: 422A9347E772D2D0183F281953DE6D520F33B9BB5282EB48F3883E3EA940C2409AC8A926ABB75FE7905B0C056AE2199A
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 86400 (seconds)
TLS session ticket:
<snip>
...
Start Time: 1617772842
Timeout : 7200 (sec)
Verify return code: 19 (self signed certificate in certificate chain)
Extended master secret: no
Max Early Data: 0
---
read R BLOCK
...
(and yes I know I should get a properly signed cert, but it's just a "home setup" ;) )
Thanks @rawbertp !
It looks like, in this case, openssl isn't able to establish trust for the certificate served by elasticsearch-master:9200 using that CA file either:
Verify return code: 19 (self signed certificate in certificate chain)
There seems to be something amiss with the certificates.
If you wanted to share the public parts of each certificate here (the one being served and the CA file), I could help troubleshoot a bit more.
Hey @jszwedko ! Thank you very much for offering your help. Let me clear this up on my end first - I'm pretty sure you're right and something is wrong with my certificates.