Ayush0612005 opened a new pull request, #31066: URL: https://github.com/apache/camel/pull/31066
# Description [CAMEL-25650](https://issues.apache.org/jira/browse/CAMEL-25650): the JSSE configuration utility had no way to ask for host name verification. `SSLContextClientParameters` gets an optional `endpointIdentificationAlgorithm` (for example `HTTPS` or `LDAPS`). `BaseSSLContextParameters` applies it in the `SSLSocket` configurer that already sets the SNI host names, so every client socket that the `SSLSocketFactory` of the context creates checks the server's certificate against the host it connects to. It may use a property placeholder, as the SNI host names do. On the points for discussion in the ticket: - **Default**: unset, which keeps today's behavior. Defaulting to `HTTPS` would be a breaking change for every component that uses the utility, which the ticket leaves to a project decision, so this PR only adds the opt-in. The security policy (`camel.main.profile = prod`) could require it later. - **Per-component flags**: nothing changes for them. A component that sets the algorithm on its own socket or engine still does. - **The peer has to be attached**: the JDK matches against the host the socket was created with, so `createSocket(host, port)` works and an unconnected `createSocket()` fails the handshake. The Javadoc and the user manual say so. - **`SSLEngine` is not covered**: an engine starts in server mode (`SSLContext.createSSLEngine()` returns `getUseClientMode() == false`), and components switch it to client mode after the utility has configured it. Setting it on a server-mode engine that requests client authentication may make the JDK check the client's certificate against the client's address, so applying it to every engine risks breaking mutual TLS servers. A component that uses an engine can read `getEndpointIdentificationAlgorithm()` and apply it once the engine is in client mode; I can follow up for the netty-based components if that direction is fine. Not in this PR: the Spring/Blueprint XML attribute (`AbstractSSLContextClientParametersFactoryBean`) and the `camel.ssl.*` main options. They can follow once the option is agreed. # Tests New `SSLContextClientParametersEndpointIdentificationTest`, with a real TLS handshake against an `SSLServerSocket` that uses the `localhost.p12` test certificate (issued to `localhost` only), and a client that trusts it: - unset: a client connecting to `127.0.0.1` completes the handshake, as before; - `HTTPS`: a client connecting to `localhost` completes the handshake, and one connecting to `127.0.0.1` fails with `SSLHandshakeException`; - a property placeholder is resolved; - an `SSLEngine` of the context does not get the algorithm. With the line that sets the algorithm removed, the `HTTPS` and placeholder tests fail. The JSSE tests of camel-core pass (82). # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I built camel-api with `install` (including `formatter:format` and `impsort:sort`). _Claude Code on behalf of Ayush0612005_ -- 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]
