このコンテンツは選択した言語では利用できません。
4.5. Tutorial II: SSL/TLS Security
Overview
This tutorial shows you how to enable an SSL/TLS endpoint on the broker and how to configure the example JMS consumer and producer clients so that they can connect to the secure endpoint.
Tutorial steps
To configure SSL/TLS security for a broker deployed in the OSGi container, perform the following steps:
Install sample keystore files
The broker requires the following keystore files:
- Key store containing broker's own certificate and private key—used to identify the broker during an SSL handshake.
- Trust store containing CA certificate—used to verify that a received client certificate is correctly signed (strictly speaking, the trust store file is only needed by the broker, if the
transport.needClientAuth
options is set totrue
on the broker URI).
For this tutorial, you can use the demonstration certificates provided with the Apache ActiveMQ distribution, in
ActiveMQInstallDir
.
Copy the
broker.ks
and broker.ts
files from the Apache ActiveMQ distribution's conf
directory, ActiveMQInstallDir/conf
, to the InstallDir/etc
directory of JBoss A-MQ.
Warning
The demonstration broker key store and broker trust sture are provided for testing purposes only. Do not deploy these certificates in a production system. To set up a genuinely secure SSL/TLS system, you must generate custom certificates, as described in Appendix A, Managing Certificates.
Configure the broker
Use your favorite text editor to edit the file,
InstallDir/etc/activemq.xml
, adding the highlighted XML fragments:
<?xml version="1.0" encoding="UTF-8"?> <beans ...> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="${broker-name}" dataDirectory="${data}" start="false"> ... <sslContext> <sslContext keyStore="${karaf.base}/etc/broker.ks" keyStorePassword="password" trustStore="${karaf.base}/etc/broker.ts" trustStorePassword="password" /> </sslContext> <transportConnectors> <transportConnector name="ssl" uri="ssl://0.0.0.0:61617?transport.enabledProtocols=TLSv1,TLSv1.1,TLSv1.2&maximumConnections=1000"/> </transportConnectors> </broker> </beans>
Note the following key aspects of the broker configuration:
- The Openwire network connector is configured to use SSL,
ssl://localhost:61617?...
. - The enabled protocols are specified explicitly, using the
transport.enabledProtocols
option. This setting effectively disables the SSLv3 protocol, which must not be used because of the POODLE security vulnerability. - The key store and trust store file locations and passwords are specified by the broker's
sslContext
element.
Warning
If you are planning to enable SSL/TLS security, you must ensure that you explicitly disable SSLv3 protocol, in order to safeguard against the Poodle vulnerability (CVE-2014-3566). For more details, see Disabling SSLv3 in JBoss Fuse 6.x and JBoss A-MQ 6.x.
Start the JBoss A-MQ container
Change directory to
InstallDir/bin
and enter the following command:
./amq
Configure the consumer and the producer clients
To test the broker configured in the OSGi container, you are going to use the example consumer tool and producer tool supplied with the Apache ActiveMQ installation.
Configure the consumer and the producer clients to pick up the client trust store. Edit the Ant build file,
ActiveMQInstallDir/example/build.xml
, and add the javax.net.ssl.trustStore
and javax.net.ssl.trustStorePassword
JSSE system properties to the consumer target and the producer target as shown in the following example:
<project ...> ... <target name="consumer" depends="compile" description="Runs a simple consumer"> ... <java classname="ConsumerTool" fork="yes" maxmemory="100M"> <classpath refid="javac.classpath" /> <jvmarg value="-server" /> <sysproperty key="activemq.home" value="${activemq.home}"/> <sysproperty key="javax.net.ssl.trustStore" value="${activemq.home}/conf/client.ts"/> <sysproperty key="javax.net.ssl.trustStorePassword" value="password"/> <arg value="--url=${url}" /> ... </java> </target> <target name="producer" depends="compile" description="Runs a simple producer"> ... <java classname="ProducerTool" fork="yes" maxmemory="100M"> <classpath refid="javac.classpath" /> <jvmarg value="-server" /> <sysproperty key="activemq.home" value="${activemq.home}"/> <sysproperty key="javax.net.ssl.trustStore" value="${activemq.home}/conf/client.ts"/> <sysproperty key="javax.net.ssl.trustStorePassword" value="password"/> <arg value="--url=${url}" /> ... </java> </target> ... </project>
In the context of the Ant build tool, this is equivalent to adding the system properties to the command line.
Run the consumer with the SSL protocol
To connect the consumer tool to the
ssl://localhost:61617
endpoint (Openwire over SSL), change directory to ActiveMQInstallDir/example
and enter the following command:
ant consumer -Duser=admin -Dpassword=admin -Durl=ssl://localhost:61617 -Dmax=100
You should see some output like the following:
Buildfile: build.xml init: compile: consumer: [echo] Running consumer against server at $url = ssl://localhost:61617 for subject $subject = TEST.FOO [java] Connecting to URL: ssl://localhost:61617 (admin:admin) [java] Consuming queue: TEST.FOO [java] Using a non-durable subscription [java] Running 1 parallel threads [java] [Thread-2] We are about to wait until we consume: 100 message(s) then we will shutdow
Run the producer with the SSL protocol
To connect the producer tool to the
ssl://localhost:61617
endpoint, open a new command prompt, change directory to example
and enter the following command:
ant producer -Duser=admin -Dpassword=admin -Durl=ssl://localhost:61617 -Dmax=100
In the window where the consumer tool is running, you should see some output like the following:
[java] [Thread-2] Received: 'Message: 0 sent at: Tue Mar 19 10:07:25 CET 2013 ...' (length 1000) [java] [Thread-2] Received: 'Message: 1 sent at: Tue Mar 19 10:07:25 CET 2013 ...' (length 1000) [java] [Thread-2] Received: 'Message: 2 sent at: Tue Mar 19 10:07:26 CET 2013 ...' (length 1000) [java] [Thread-2] Received: 'Message: 3 sent at: Tue Mar 19 10:07:26 CET 2013 ...' (length 1000) [java] [Thread-2] Received: 'Message: 4 sent at: Tue Mar 19 10:07:26 CET 2013 ...' (length 1000)