Camel + RabbitMQ + SSL

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Camel + RabbitMQ + SSL

pwillemann
Hello:

I am using Camel 2.24.3 and RabbitMQ 3.17.7.   I have been able to
successfully build a Camel program to ingest data from my input source and
send the results to RabbitMQ.   I am happy with the results.  Now I am
required to use SSL between my Camel program and RabbitMQ. Both my Camel
program and RabbitMQ Server are on the same Windows 10 machine.

1. I have configured RabbitMQ to expect TLS connections at port 5671 and I
am pretty sure this is working because the rabbitmq utilities are working
and give me the diagnostics I expect.
2. What I am less sure of is the configuration of my Camel context file.

I have added two beans to my context to enable me to work with SSL and
RabbitMQ

                 <bean id="clientConnectionFactory"
       
class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBea
n">
                <property name="useSSL" value="true" />
        </bean>

        <bean id="rabbitConnectionFactory"
class="com.rabbitmq.client.ConnectionFactory">
               
                <property name="host"
                        value="#{systemEnvironment['AMQP_BROKER_HOST']}" />
                <property name="port"
                        value="#{systemEnvironment['AMQP_BROKER_PORT']}" />
                <property name="username"
                        value="#{systemEnvironment['AMQP_BROKER_USERNAME']}"
/>
                <property name="password"
                        value="#{systemEnvironment['AMQP_BROKER_PASSWORD']}"
/>
        </bean>

I am pretty sure this is correct.   I know the rabbitConnectionFactory is
correct because it is what I use for the non-SSL version.  Here is part of
the route that I have my question:

<to
uri="rabbitmq:{{amqp.exchange.track}}?exchangeType=topic&amp;autoDelete=true
&amp;durable=false&amp;routingKey={{amqp.exchange.routingkey}}&amp;sslProtoc
ol=true&amp;hostname=localhost" />

I have only added two parameters to my non-SSL route - the sslProtocol and
hostname.

1. I tried just sslProtocol by itself and the error output said I needed a
hostname
2. I added the hostname and now the error output says:  "Address is invalid
on local machine, or port is not valid remote machine"
3. A google search has not yielded anything that I have found to fix the
problem.  I am still searching, however I thought posting here might be a
good idea.

Thanks
Respectfully
Phil Willemann





smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Camel + RabbitMQ + SSL

Tom Donohue-2
Hi Phil,

I presume that the camel-rabbitmq component is picking up and using this
ConnectionFactory:

<bean id="rabbitConnectionFactory"
class="com.rabbitmq.client.ConnectionFactory">...</bean>

So I would see if SSL needs to be configured there, and not on the Camel
endpoint. Try setting the "useSslProtocol" [1] property on the
ConnectionFactory itself?  (i.e. set it as a property alongside host, port,
username, password, etc.)

[1]: https://www.rabbitmq.com/ssl.html#java-client-connecting

Hope this helps?

Tom


On Tue, 14 Apr 2020 at 21:55, Willemann, Phil <[hidden email]>
wrote:

> Hello:
>
> I am using Camel 2.24.3 and RabbitMQ 3.17.7.   I have been able to
> successfully build a Camel program to ingest data from my input source and
> send the results to RabbitMQ.   I am happy with the results.  Now I am
> required to use SSL between my Camel program and RabbitMQ. Both my Camel
> program and RabbitMQ Server are on the same Windows 10 machine.
>
> 1. I have configured RabbitMQ to expect TLS connections at port 5671 and I
> am pretty sure this is working because the rabbitmq utilities are working
> and give me the diagnostics I expect.
> 2. What I am less sure of is the configuration of my Camel context file.
>
> I have added two beans to my context to enable me to work with SSL and
> RabbitMQ
>
>                  <bean id="clientConnectionFactory"
>
>
> class="org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBea
> n">
>                 <property name="useSSL" value="true" />
>         </bean>
>
>         <bean id="rabbitConnectionFactory"
> class="com.rabbitmq.client.ConnectionFactory">
>
>                 <property name="host"
>                         value="#{systemEnvironment['AMQP_BROKER_HOST']}" />
>                 <property name="port"
>                         value="#{systemEnvironment['AMQP_BROKER_PORT']}" />
>                 <property name="username"
>
> value="#{systemEnvironment['AMQP_BROKER_USERNAME']}"
> />
>                 <property name="password"
>
> value="#{systemEnvironment['AMQP_BROKER_PASSWORD']}"
> />
>         </bean>
>
> I am pretty sure this is correct.   I know the rabbitConnectionFactory is
> correct because it is what I use for the non-SSL version.  Here is part of
> the route that I have my question:
>
> <to
>
> uri="rabbitmq:{{amqp.exchange.track}}?exchangeType=topic&amp;autoDelete=true
>
> &amp;durable=false&amp;routingKey={{amqp.exchange.routingkey}}&amp;sslProtoc
> ol=true&amp;hostname=localhost" />
>
> I have only added two parameters to my non-SSL route - the sslProtocol and
> hostname.
>
> 1. I tried just sslProtocol by itself and the error output said I needed a
> hostname
> 2. I added the hostname and now the error output says:  "Address is invalid
> on local machine, or port is not valid remote machine"
> 3. A google search has not yielded anything that I have found to fix the
> problem.  I am still searching, however I thought posting here might be a
> good idea.
>
> Thanks
> Respectfully
> Phil Willemann
>
>
>
>
>