ramu11 commented on PR #31121:
URL: https://github.com/apache/camel/pull/31121#issuecomment-7282489864

   > Strong addition, and it closes a real gap: Kafka only understands 
file-based `ssl.*` properties, so until now there was no way to hand 
`camel-kafka` a Camel `SSLContextParameters` (in-memory keystores, a shared 
JSSE config, vault-resolved material). Bridging that through Kafka's 
`SslEngineFactory` SPI is the correct and idiomatic way to do it. I read the 
engine factory and the configuration wiring closely, and the security-relevant 
parts all hold up:
   > 
   > * `CamelSslEngineFactory` fails closed: `configure` throws if the SSL 
context is absent rather than falling back to a default engine, and 
`getSslContext` throws if it was never configured. There is no silent insecure 
path.
   > * `createClientSslEngine` carries `endpointIdentificationAlgorithm` 
through to the engine's `SSLParameters`, so Kafka's hostname verification 
(default `https`) still applies. That is the detail most custom engine 
factories get wrong, and getting it right here means TLS does not silently lose 
host checking.
   > * `KafkaClientConfiguration.configureSslEngineFactory` only installs the 
factory when the security protocol is actually SSL, and otherwise removes the 
factory class, the endpoint-identification and the internal context key. So a 
plaintext or SASL-plaintext endpoint never gets the SSL machinery attached.
   > * The live `SSLContext` is passed to the factory via the internal 
`camel.ssl.context` key, and the `additionalProperties` handling deliberately 
drops any user-supplied `ssl.*` entries and any attempt to set that internal 
key when `sslContextParameters` is configured, logging the ignored ones once. 
That both documents the precedence and stops a user from quietly overriding the 
Camel-provided context.
   > * `getOrCreateSslContext` uses double-checked locking with a `volatile` 
field and wraps a build failure in a clear exception, and the cache is reset on 
`copy()`.
   > 
   > Documentation and coverage are in order: the option is described on both 
`camel-kafka` and `camel-kafka-share`, the camel-configuration-utilities page 
is updated, the generated catalog and DSL are regenerated in step, and 
`KafkaSslContextParametersTest` / `KafkaClientConfigurationSslTest` exercise 
the path. Because the option is additive and defaults to unset, existing 
`ssl.*`-configured endpoints are unaffected, so I agree no upgrade-guide entry 
is needed.
   > 
   > One thing worth a quick check (I could not verify it without a running 
broker): passing the `SSLContext` as a non-String value under 
`camel.ssl.context` may make the Kafka client log its usual "configuration was 
supplied but isn't a known config" line for that key at startup. If it does, it 
is cosmetic, but a note in the docs or filtering it from what reaches the 
client logger would avoid a confused user. Not a blocker.
   > 
   > Nicely done, and consistent with the SSLContextParameters support you 
added to smpp.
   > 
   > _Claude Code on behalf of oscerd_
   
   Thanks a lot for the thorough review and the positive feedback.
   
   I've pushed an update addressing the additional review feedback.
   
   A few details worth highlighting:
   
   - The SSL engine factory continues to fail fast if the Camel-created 
`SSLContext` is missing, and hostname verification through 
`endpointIdentificationAlgorithm` is preserved.
   - The custom factory is only configured for SSL-enabled security protocols. 
The existing `security.protocol=PLAINTEXT` override through 
`additionalProperties` continues to work.
   - The SSL context is now created separately for each Kafka client rather 
than cached at endpoint-configuration level, so newly created clients can pick 
up rotated key and trust material.
   - Added an explicit named-groups and signature-schemes test that exercises 
Kafka's own `SslFactory`, including configuration of the custom factory and 
creation of a client `SSLEngine`.
   
   Regarding the internal `camel.ssl.context` property: the new test exercises 
Kafka's `SslFactory.configure()` with this non-String property and verifies 
that the custom factory receives the Camel `SSLContext` and creates the engine 
successfully. I have not added a specific assertion for Kafka's configuration 
logging during full producer/consumer startup, so I cannot yet rule out the 
cosmetic unknown-configuration message you mentioned. The property is required 
to pass the Camel-created `SSLContext` to Kafka's `SslEngineFactory`.
   
   I also added the 4.25 upgrade-guide entry because, although the feature is 
opt-in, existing endpoints that combine `sslContextParameters` with 
Kafka-specific SSL options will observe the changed precedence.
   
   The updated Kafka module verification completed successfully, including 
1,040 unit tests and all 4 Kafka Share integration tests.
   
   Thanks again for reviewing this and for the helpful suggestions.


-- 
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]

Reply via email to