From 9335cd83ed0b2bdc12d72d24e88eb67cf3ddf7d1 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Thu, 29 Oct 2020 08:48:16 -0400 Subject: [PATCH] ARTEMIS-2937 Changing BrokerConnection SSL example to also use SSL on the client --- .../features/broker-connection/amqp-sending-overssl/pom.xml | 2 +- .../artemis/jms/example/BrokerConnectionSenderSSL.java | 6 +++--- .../src/main/resources/activemq/server0/broker.xml | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/features/broker-connection/amqp-sending-overssl/pom.xml b/examples/features/broker-connection/amqp-sending-overssl/pom.xml index c1dc3b83ca..6b0d6448b0 100644 --- a/examples/features/broker-connection/amqp-sending-overssl/pom.xml +++ b/examples/features/broker-connection/amqp-sending-overssl/pom.xml @@ -102,7 +102,7 @@ under the License. true ${noServer} ${basedir}/target/server0 - tcp://localhost:5660 + tcp://localhost:5671 run diff --git a/examples/features/broker-connection/amqp-sending-overssl/src/main/java/org/apache/activemq/artemis/jms/example/BrokerConnectionSenderSSL.java b/examples/features/broker-connection/amqp-sending-overssl/src/main/java/org/apache/activemq/artemis/jms/example/BrokerConnectionSenderSSL.java index bc0ab978f0..f7145ae847 100644 --- a/examples/features/broker-connection/amqp-sending-overssl/src/main/java/org/apache/activemq/artemis/jms/example/BrokerConnectionSenderSSL.java +++ b/examples/features/broker-connection/amqp-sending-overssl/src/main/java/org/apache/activemq/artemis/jms/example/BrokerConnectionSenderSSL.java @@ -35,7 +35,7 @@ public class BrokerConnectionSenderSSL { public static void main(final String[] args) throws Exception { Connection connectionOnServer0 = null; - ConnectionFactory connectionFactoryServer0 = new JmsConnectionFactory("amqp://localhost:5660"); + ConnectionFactory connectionFactoryServer0 = new JmsConnectionFactory("amqps://localhost:5672?transport.trustStoreLocation=target/server0/etc/activemq.example.truststore&transport.trustStorePassword=activemqexample&transport.verifyHost=false"); // Step 1. Create a connection on server0, and send a few messages try { @@ -50,7 +50,7 @@ public class BrokerConnectionSenderSSL { sender.send(session.createTextMessage("Hello world overSSL n" + i)); } } finally { - if (connectionFactoryServer0 != null) { + if (connectionOnServer0 != null) { connectionOnServer0.close(); } } @@ -58,7 +58,7 @@ public class BrokerConnectionSenderSSL { // Step 2. create a connection on server1, and receive a few messages. // the sender on the broker conneciton will take care of the transfer. Connection connectionOnServer1 = null; - ConnectionFactory connectionFactoryServer1 = new JmsConnectionFactory("amqp://localhost:5771"); + ConnectionFactory connectionFactoryServer1 = new JmsConnectionFactory("amqps://localhost:5772?transport.trustStoreLocation=target/server1/etc/activemq.example.truststore&transport.trustStorePassword=activemqexample&transport.verifyHost=false"); try { connectionOnServer1 = connectionFactoryServer1.createConnection(); diff --git a/examples/features/broker-connection/amqp-sending-overssl/src/main/resources/activemq/server0/broker.xml b/examples/features/broker-connection/amqp-sending-overssl/src/main/resources/activemq/server0/broker.xml index 8aea83cf33..3ecd7dcc88 100644 --- a/examples/features/broker-connection/amqp-sending-overssl/src/main/resources/activemq/server0/broker.xml +++ b/examples/features/broker-connection/amqp-sending-overssl/src/main/resources/activemq/server0/broker.xml @@ -31,7 +31,8 @@ under the License. - tcp://0.0.0.0:5660?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true + tcp://0.0.0.0:5671?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true + tcp://localhost:5672?sslEnabled=true;keyStorePath=activemq.example.keystore;keyStorePassword=activemqexample;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE