davsclaus opened a new pull request, #30349: URL: https://github.com/apache/camel/pull/30349
[CAMEL-27206](https://issues.apache.org/jira/browse/CAMEL-27206) When camel-nats connects with TLS (`secure=true`, or a `tls://` server address), jnats checks the certificate of the server against the trust store, but not that the certificate was issued for the host it connects to. ## Changes - New `hostnameVerification` option (default `true`, marked `insecure:ssl` when `false`), as camel-smpp, camel-mina and camel-mllp have. - When TLS is used and the option is on, the `SSLContext` that jnats gets is wrapped (`HostnameVerifyingSSLContext`), so its sockets and engines set the endpoint identification algorithm `HTTPS`. - jnats replaces a host name by its IP addresses before it connects by default, so TLS would only see an IP address (`noResolveHostnames()` is `ResolveToFirst` in jnats 2.26, and still resolves). With the check on, the options use `HostnameResolveMode.HappyEyeballs`, which connects to the fastest IP address of the host name and keeps the name for TLS. (`Unresolved` did not connect in the test.) - `opentls://` addresses, which ask jnats to trust any certificate, are left as they are. - Upgrade guide entry for 4.24, including the servers that a NATS cluster announces by IP address. ## Tests - `NatsHostnameVerificationTest`: a local server sends the INFO line of a NATS server that requires TLS and does the handshake with a certificate for `localhost` only: connecting to `127.0.0.1` fails, connecting to `localhost` succeeds, and `hostnameVerification=false` accepts it for `127.0.0.1`. - The camel-nats unit tests pass (1049). _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
