Introduction
In my previous blog http://ggl-consulting.blogspot.com/2015/02/configure-activemq-transport-connector.html, I have explained the activemq configuration with mutual authentication. In most case, we don't need to have the server to check client's certificates, but rather client just need to send the server's certificate, or broker trust store together with client key.
I should point out that in large enterprise, normally the certificates are not generated by admin. There will be certified organization to issue the certificates. My blogs are just demonstrate how to setup ActiveMQ and run the producers and consumers.
All the certificate generation procedures are still the same except that we don't need to generate broker.ts file. For the completeness, I will provide the complete procedure in this blog, including how to run the producers and consumers.
Generate Keystore and Truststore
For one-way authentication, we will need 3 files as the following:
- broker.ks : server keystore
- client.ks : client keystore
- client.ts : client truststore
Here is the procedure to generate these files:
cd $ACTIVEMQ_HOME/conf keytool -genkey -alias broker -keyalg RSA -keystore broker.ks keytool -genkey -alias client -keyalg RSA -keystore client.ks keytool -export -alias broker -keystore broker.ks -file broker_cert keytool -import -alias broker -keystore client.ts -file broker_cert
Modify activemq.xml
... ...
For large network of ActiveMQ Clustering, please refer my other blog: http://ggl-consulting.blogspot.com/2015/03/broker-to-broker-network-connector-with.html
As you can see, comparing the two-authentication case, we only need the keyStore of the broker, which include the broker's key and certificates
Run Producer and Consumer
For running producer, I have created a scrirpt named runProducerOneWay.sh with the following contents:
#!/bin/bash ACTIVEMQ_HOME=/opt/app/amq/Transport/NioSsl ant producer -Durl="nio+ssl://localhost:61617" \ -Dtopic=false \ -Ddurable=true \ -Dsubject=QUEUE.NIOSSL \ -Dmax=100 \ -Djavax.net.ssl.keyStore=${ACTIVEMQ_HOME}/conf/client.ks \ -Djavax.net.ssl.keyStorePassword=amqadmin@ \ -Djavax.net.ssl.trustStore=${ACTIVEMQ_HOME}/conf/client.ts
Run the above script at $ACTIVEMQ_HOME/examples/openwire/swissarmy
The script for running consumer, namely, runConsumerOneWay.sh has the following contents:
#!/bin/bash ACTIVEMQ_HOME=/opt/app/amq/Transport/NioSsl ant consumer -Durl="nio+ssl://localhost:61617" \ -Dtopic=false \ -Ddurable=true \ -Dsubject=QUEUE.NIOSSL \ -Djavax.net.ssl.keyStore=${ACTIVEMQ_HOME}/conf/client.ks \ -Djavax.net.ssl.keyStorePassword=amqadmin@ \ -Djavax.net.ssl.trustStore=${ACTIVEMQ_HOME}/conf/client.ts
As you can see, we don't need to know the server's keyStore password. We still need the client's keyStore information in order for the server to know the decryption algorithms.
Hi Gary ,
ReplyDeleteI have a quick question , how do i change the existing tcp to ssl with out changing any client code ? because my clients are using tcp till now and we are moving amazon mq which supports only ssl with the authentication on connection with user id and pwd ?
how do i do that the current tcp to be changed to ssl and supporting the clients to not to refactor a lot interms of connection credentials as well ? In my ase i dont require mutual authentication , i just have my clients to talk to ssl instead of tcp ..pls throw up any recommendations to change.
helpful and insightful blog
ReplyDeleteData science Courses in Manchester