davsclaus opened a new pull request, #3211:
URL: https://github.com/apache/camel-kamelets/pull/3211

   Fixes #3210
   
   ## Problem
   
   `spring-rabbitmq-source` and `spring-rabbitmq-sink` offer `protocol: amqps` 
for a TLS connection to the broker. They created a Spring 
`CachingConnectionFactory` from the URI `{{protocol}}://{{host}}:{{port}}`, and 
for an `amqps://` URI the RabbitMQ client sets up TLS with its own default, 
which neither checks the broker certificate against a trust store nor compares 
the host name of the broker with the certificate. The Kamelets also had no 
option to give a trust store.
   
   ## Change
   
   - Both Kamelets now create the RabbitMQ `ConnectionFactory` with Spring 
AMQP's `RabbitConnectionFactoryBean` (a `builderClass` bean, `getObject` as 
builder method) and wrap it in `CachingConnectionFactory` (constructor 
argument). The sink keeps `publisherConfirmType` on the caching factory.
     - The `protocol` option and its default `amqp` stay. 
`RabbitConnectionFactoryBean` turns TLS on for an `amqps://` URI and sets it up 
before it applies the URI: with no trust store given it uses the default trust 
store of Java, and it enables host name verification by default.
   - New options `sslTruststoreLocation` and `sslTruststorePassword` (`format: 
password`, credentials descriptor), mapped to `trustStore` and 
`trustStorePassphrase` of `RabbitConnectionFactoryBean`. The location is a 
Spring resource location, such as `file:/etc/rabbitmq/truststore.p12` or 
`classpath:truststore.p12` (a path without `file:` is looked up on the 
classpath); JKS and PKCS12 both load. There is no option to turn the checks 
off. The names follow the trust store options of the Kafka and MQTT Kamelets.
   - The `protocol` description and the Good to know of both Kamelets say what 
`amqps` now checks.
   - Regenerated: the library copies of both Kamelets and `kamelets-index.json`.
   
   ## Behaviour change
   
   With `protocol: amqps`, a broker whose certificate Java does not trust, or 
whose certificate does not name the host in `host`, no longer connects. Add the 
CA of such a broker to the trust store of Java, or give it with 
`sslTruststoreLocation`. `protocol: amqp` (the default) is unchanged. This 
needs a line in the upgrade notes of #3190 (and so in the Camel 4.24 upgrade 
guide).
   
   ## Tests
   
   `SpringRabbitmqKameletTlsTest` (in `camel-kamelets-catalog`, which now has 
`camel-kamelet`, `camel-spring-rabbitmq`, `camel-core-languages` and 
`junit-jupiter-params` as test dependencies) runs both Kamelets from 
`kamelets/` against a local server, no broker or container needed:
   
   - `amqpsChecksBrokerCertificateWithJavaTrustStore`: a self-signed broker 
certificate fails the TLS handshake.
   - `amqpsAcceptsBrokerCertificateFromTrustStore`: the same certificate in 
`sslTruststoreLocation` passes.
   - `amqpsVerifiesBrokerHostName`: with that trust store, connecting by IP 
address to a certificate that only names `localhost` fails.
   - `amqpConnectsWithoutTls`: `amqp` sends the plain AMQP protocol header.
   
   The test key store and trust store are in 
`src/test/resources/spring-rabbitmq/` (generated with `keytool`, valid for 100 
years, password `changeit`).
   
   With the old templates, `amqpsChecksBrokerCertificateWithJavaTrustStore` and 
`amqpsVerifiesBrokerHostName` fail for both Kamelets (the handshake succeeds). 
`./mvnw clean install` passes.
   
   To be ported by hand to `4.22.x` and `4.18.x`.
   
   _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]

Reply via email to