Elasticsearch TLS hostname verification with verification_mode=certificate and DNS round-robin load balancing
0 reputation · 06 Oct 2025, 02:46 UTC
0 reputation · 06 Oct 2025, 02:46 UTC
Determine whether Elasticsearch performs a reverse DNS lookup on the remote IP address when verification_mode is set to certificate and how the JVM's networkaddress.cache.ttl influences the hostname used in the TLS handshake when the underlying DNS record uses round-robin load balancing.
In versions prior to 8.12, Elasticsearch has been observed to execute a reverse DNS lookup for logging even though hostname validation is skipped, producing unexpected log entries. It is unclear whether this lookup is an intentional diagnostic feature or an oversight. Additionally, Elasticsearch caches DNS results according to the JVM's networkaddress.cache.ttl setting, which can cause the node to continue using a stale IP address after the DNS record changes, potentially affecting which certificate is presented and whether verification succeeds.
verification_mode=certificate a deliberate logging mechanism or an unintended side‑effect?networkaddress.cache.ttl value affect the hostname used in the TLS handshake (and thus the certificate presented) when verification_mode skips hostname validation?29275 reputation · 06 Oct 2025, 14:46 UTC
verification_mode=certificate Elasticsearch performs a reverse DNS lookup only for diagnostic logging. It is not part of the TLS verification process and does not influence which certificate the server presents.networkaddress.cache.ttl: The JVM cache controls how long a forward DNS answer (the IP chosen for the SNI hostname) is kept. A long TTL can keep the node bound to a stale IP, thereby keeping the same certificate until the TTL expires. The reverse lookup used for logging is also cached, but it does not affect the handshake.The verification_mode=certificate setting tells the Elasticsearch SSL layer to trust a peer only if the certificate chain is signed by a trusted CA and the certificate is within its validity period. Hostname/SAN matching is skipped. The TLS handshake still uses the SNI string supplied by the client, which comes from the forward DNS resolution of the hostname you configured.
Elasticsearch’s security code historically resolves the remote IP to a hostname and logs it for audit purposes. This reverse lookup is a logging side‑effect, not a verification step, and is performed even when hostname validation is disabled.
Because the JVM’s networkaddress.cache.ttl (or sun.net.inetaddr.ttl) governs all InetAddress resolutions, it affects both the forward lookup that determines which IP to connect to and the reverse lookup that is logged. A cached forward answer can keep a node connected to the same IP (and thus the same certificate) even after the round‑robin DNS record has changed.
Check the JVM cache setting on each Elasticsearch node. The effective value is usually defined in JAVA_OPTS or jvm.options as -Dsun.net.inetaddr.ttl=60 (60 s is the default). You can also inspect java.security on the node for networkaddress.cache.ttl entries.
Enable SSL debug logging to see if a reverse PTR lookup occurs. Add -Djavax.net.debug=ssl to the JVM options or set the Elasticsearch SSL logger to DEBUG or TRACE level. Restart the node and observe the logs when a client connects.
Test round‑robin behavior by creating two simple HTTP servers behind a round‑robin A record that each present a distinct certificate. Point an Elasticsearch client (or another TLS client) at the hostname, then flip the DNS record to the other IP. With a long networkaddress.cache.ttl, the client should continue to connect to the original IP and receive the original certificate until the TTL expires.
Review release notes for the exact Elasticsearch 8.x minor version you are running. The 8.12 release notes do not mention removal of reverse‑DNS logging, but the source code for org.elasticsearch.transport.netty.ssl should be examined if you suspect a change.
Providing these details will allow a precise assessment of whether the reverse‑DNS lookup behavior has been modified in your environment.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.