davsclaus opened a new issue, #3210:
URL: https://github.com/apache/camel-kamelets/issues/3210
## Description
`spring-rabbitmq-source` and `spring-rabbitmq-sink` support TLS through the
`protocol` option (`amqp` or `amqps`). Both Kamelets create a Spring
`CachingConnectionFactory` from the URI `{{protocol}}://{{host}}:{{port}}`, and
the RabbitMQ client (`com.rabbitmq.client.ConnectionFactory.setUri`) sets up
TLS for an `amqps://` URI with its built-in default, which does not check the
broker certificate against a trust store and does not verify the host name. The
Kamelets also have no option to point at a trust store, so a broker with a
certificate from a private CA cannot be configured explicitly either.
This issue changes the Kamelets so that `amqps` uses the trust store of Java
and checks the host name, and adds trust store options (as listed for the
RabbitMQ Kamelets in #3170).
## Current Behavior
- `protocol: amqps`: the connection uses TLS, but the broker certificate is
not checked against any trust store and the host name of the broker is not
compared with the certificate.
- No option to set a trust store or its password.
## Expected Behavior
- `protocol: amqps`: the broker certificate is checked with the default
trust store of Java (or the configured one), and the host name of the broker
must match the certificate. A connection to a broker whose certificate does not
pass these checks fails.
- `protocol: amqp` (the default): unchanged, no TLS.
- New options: `trustStore` (location), `trustStorePassword` (`format:
password`) and possibly `trustStoreType`. No option to turn the checks off.
## Proposed Change
- Build the RabbitMQ `ConnectionFactory` with Spring AMQP's
`org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean`
instead of handing an `amqps://` URI to `setUri`: set `host`, `port`,
`virtualHost`, `username`, `password` and `useSSL` (derived from `protocol`),
plus the trust store options, and call `afterPropertiesSet`. With `useSSL=true`
this bean uses the default `TrustManagerFactory` of Java (or the given trust
store) and enables host name verification by default.
- Wrap it in `CachingConnectionFactory` (constructor argument), keeping
`publisherConfirmType` on the sink.
- Keep the `protocol` option and its default `amqp` for compatibility.
- Files: `kamelets/spring-rabbitmq-source.kamelet.yaml`,
`kamelets/spring-rabbitmq-sink.kamelet.yaml`, their copies under
`library/camel-kamelets`, and the regenerated docs.
- Update the description (Good to know) of both Kamelets: with `amqps` the
broker certificate must be trusted by Java (or by the configured trust store)
and its name must match the broker host; a broker with a self-signed or
private-CA certificate needs that CA in the trust store.
## Tests
- Without a broker: load each Kamelet with `protocol=amqps` and assert that
the connection factory uses TLS with the default trust managers of Java and
host name verification on (e.g. `amqpsUsesJavaTrustStore`,
`amqpsVerifiesBrokerHostName`); with `protocol=amqp` assert no TLS
(`amqpConnectsWithoutTls`).
- Optionally a Citrus integration test against a TLS-enabled RabbitMQ
container with a certificate from a test CA: with the trust store option the
sink delivers, without it the connection is refused.
## Additional Context
Behaviour change for users: an `amqps` broker whose certificate Java does
not trust, or whose name does not match the certificate, no longer connects. It
will be noted in the descriptions of both Kamelets and in the upgrade notes
(#3190). To be ported to the 4.22.x and 4.18.x branches.
--
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]