Skip to content

Fix #3210: spring-rabbitmq Kamelets check the broker certificate and host name with amqps, and take a trust store - #3211

Merged
davsclaus merged 1 commit into
apache:mainfrom
davsclaus:ci-issue-3210
Nov 18, 2026
Merged

davsclaus merged 1 commit into
apache:mainfrom
davsclaus:ci-issue-3210

Conversation

@davsclaus

Copy link
Copy Markdown
Contributor

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

…e and host name with amqps, and take a trust store

With protocol amqps, spring-rabbitmq-source and spring-rabbitmq-sink now
create the RabbitMQ connection factory with Spring AMQP's
RabbitConnectionFactoryBean, wrapped in a CachingConnectionFactory. TLS
then checks the certificate of the broker with the trust store of Java
and verifies the host name of the broker. Before, the Kamelets handed an
amqps:// URI to the RabbitMQ client, whose default TLS setup for such a
URI checks neither.

The new options sslTruststoreLocation and sslTruststorePassword give a
trust store for a broker with a certificate from a private or
self-signed authority.

A broker whose certificate Java does not trust, or whose certificate
does not name the host, no longer connects with amqps. The Good to know
of both Kamelets says so. protocol amqp (the default) is unchanged.

SpringRabbitmqKameletTlsTest runs both Kamelets against a local TLS
server (and a plain one for amqp).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spring-rabbitmq-source/sink - check broker certificate and host name with amqps

1 participant