ramu11 commented on PR #31121: URL: https://github.com/apache/camel/pull/31121#issuecomment-7282462903
> Thanks, this is a nice piece of work. Plugging into Kafka's `SslEngineFactory` SPI is the right approach. I checked it against the kafka-clients 4.4.0 classes: the SSLContext reaches the factory through the config originals, and `createClientSslEngine` matches what Kafka's default factory does for client mode and endpoint identification. I also like three other things: > > * `configureSslEngineFactory` runs after `additionalProperties`, so a `security.protocol=PLAINTEXT` override still works. > * No passwords end up in the Kafka properties any more. > * The share admin client gets the same TLS setup. > > A few things before this can go in: > > 1. **Upgrade guide.** This changes behaviour for existing users, so it needs an entry in `camel-4x-upgrade-guide-4_25.adoc`. [CAMEL-25106](https://issues.apache.org/jira/browse/CAMEL-25106) deliberately made the SSL endpoint options apply after `sslContextParameters` in 4.23, and the 4_23 guide documents that. With this PR, those options and the `additionalProperties` that start with `ssl.` are ignored, also when the parameters come from `useGlobalSslContextParameters`. The entry should also say: > > * named groups, signature schemes and the post-quantum preference are now applied, so with explicit `namedGroups`, a broker outside them can no longer connect; > * a `KeyManager` set directly is now accepted; > * the `jdk.tls.*` workaround from the 4_24 guide is no longer needed for Kafka. > 2. **Silently ignored endpoint options.** Only ignored `additionalProperties` get a WARN. In `applySecurityProperties` (`KafkaClientConfiguration.java`, around line 561), the `ssl*` endpoint options are dropped without a word when `sslContextParameters` is set. With global SSL, an endpoint that sets `sslTruststoreLocation` to use a stricter truststore would quietly use the global trust material instead. Could we log a WARN once that names the ignored options (names only, never values)? The docs can then say to give such an endpoint its own `sslContextParameters`. > 3. **Docs that now contradict the code.** The existing paragraph in `kafka-component.adoc` (around lines 2190-2195) still says the parameters are mapped to `ssl.*` properties, and that named groups and signature schemes are not applied. That paragraph should be replaced by your new section, or merged with it. In `camel-configuration-utilities.adoc:532`, Kafka no longer has its own TLS stack, so I would remove it from that table and drop the sentence about Kafka after it. Line 534 should also say "cipher suites" rather than "suites". > 4. **Caching the SSLContext.** `getOrCreateSslContext` creates the context once per endpoint configuration and keeps it across route restarts. Before this PR, each new Kafka client (a reconnect or a route restart) read the keystore and truststore files again, so rotated certificates were picked up. What do you think about creating it per client, or clearing it when the endpoint stops? Either way, the comment at `CamelSslEngineFactory.java:77` says a restart creates a new context, which is not the case today. > 5. **Tests.** `kafkaSslFactoryHonorsAutomaticPqcNamedGroupPreference` is the only test that goes through Kafka's own `SslFactory`. It is skipped on JDK 21, because there is no hybrid group to promote, and the JDK 25 job does not run on PRs. Could you add a variant with explicit `namedGroups` that always runs? A small loopback handshake would be even better: a client engine from Kafka's `SslFactory` against a server engine built from a test keystore. > > Smaller things: > > * In `KafkaClientConfigurationSslTest.java` (lines 157, 167, 245 and 249), please import the classes instead of using fully qualified names. With Java 21 as the baseline, `SSLParameters.getNamedGroups()` and `getSignatureSchemes()` can be called directly, without reflection. > * Two comments near the top of that test were removed: why the appender filters by thread, and why it waits for log4j to start. I would keep them, as they explain the guards against flakiness. > * `CamelSslEngineFactory.java:37`: `@since 4.24` should be `@since 4.25`. > * The Javadoc of `addSslOption` still mentions `sslContextParameters`, and its `defaultValue` parameter is now unused, so it could be simplified. > > Thanks again, this closes a real gap for Kafka TLS users. > > _Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying._ Thanks for the detailed review and helpful suggestions. I've pushed an update addressing the review comments. 1. **Upgrade guide:** Added an entry to `camel-4x-upgrade-guide-4_25.adoc` covering the changed SSL option precedence, including when `useGlobalSslContextParameters` is used. It documents support for named groups, signature schemes, automatic PQC named-group preference, and directly configured `KeyManager` instances. It also explains that the Kafka-specific `jdk.tls.*` workaround is no longer needed when using `sslContextParameters`, and describes the migration implications for existing endpoints. 2. **Ignored SSL endpoint options:** Added a warning when non-default Kafka SSL endpoint options are ignored because `sslContextParameters` is configured. The warning is emitted once per endpoint configuration and lists option names only; it never logs passwords or configured values. The documentation also explains that endpoint-specific TLS settings should be configured through endpoint-specific `sslContextParameters`. `sslEndpointAlgorithm` remains applicable. 3. **Documentation:** Replaced the outdated Kafka TLS explanation in both Kafka component documentation files with a reference to the new TLS section. Removed Kafka and Kafka Share from the own-TLS-stack table in `camel-configuration-utilities.adoc`, along with the now-obsolete Kafka JVM-property workaround note. Updated the generated catalog documentation as well. 4. **SSLContext lifecycle:** Removed the endpoint-level SSLContext cache. A new SSLContext is now created for each Kafka client configuration, allowing newly created clients after route restarts to pick up rotated key and trust material. Updated the `CamelSslEngineFactory` comment to reflect this lifecycle. 5. **Tests:** Added an explicit named-groups and signature-schemes test that exercises Kafka's own `SslFactory`. This test runs on JDK 21 and does not depend on automatic PQC group availability. The test verifies the configured groups, signature schemes, client mode, and endpoint identification. I did not add the optional loopback handshake; the new test exercises the Kafka factory integration directly. For the smaller comments: - Replaced reflection with the Java 21 `SSLParameters.getNamedGroups()` and `getSignatureSchemes()` APIs. - Restored the two comments explaining the Log4j startup wait and thread filtering. - Changed `@since` to `4.25`. - Simplified the `addSslOption` Javadoc and removed the unused `defaultValue` parameter. **Verification:** The post-rebase Maven verification completed successfully: ```bash mvn -pl components/camel-kafka-common,components/camel-kafka,components/camel-kafka-share -am clean verify ``` The reported test results include 1,040 tests with zero failures, errors, or skips, and all 4 Kafka Share integration tests passed. Thanks again for the review. -- 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]
