[ 
https://issues.apache.org/jira/browse/CAMEL-11780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16440801#comment-16440801
 ] 

ASF GitHub Bot commented on CAMEL-11780:
----------------------------------------

vrlgohel closed pull request #2046: CAMEL-11780: camel-amqp - SSL Transport 
configuration
URL: https://github.com/apache/camel/pull/2046
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPConnectionDetails.java
 
b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPConnectionDetails.java
index 029e17b781b..6e5bd3964d9 100644
--- 
a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPConnectionDetails.java
+++ 
b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPConnectionDetails.java
@@ -28,13 +28,19 @@
     public static final String AMQP_USERNAME = "AMQP_SERVICE_USERNAME";
 
     public static final String AMQP_PASSWORD = "AMQP_SERVICE_PASSWORD";
+    
+    private static final String KEYSTORE = "broker.ks";
+
+    private static final String TRUSTSTORE = "broker.ks";
+
+    private static final String PASSWORD = "password";
 
     private final String uri;
 
     private final String username;
 
     private final String password;
-
+   
     public AMQPConnectionDetails(String uri, String username, String password) 
{
         this.uri = uri;
         this.username = username;
@@ -60,6 +66,24 @@ public static AMQPConnectionDetails 
discoverAMQP(CamelContext camelContext) {
         }
     }
 
+    public static AMQPConnectionDetails discoverAMQPSsl(CamelContext 
camelContext) {
+        try {
+            PropertiesComponent propertiesComponent = 
camelContext.getComponent("properties", PropertiesComponent.class);
+
+            String host = property(propertiesComponent, AMQP_HOST, 
"localhost");
+            int port = Integer.parseInt(property(propertiesComponent, 
AMQP_PORT, "5672"));
+            String username = property(propertiesComponent, AMQP_USERNAME, 
null);
+            String password = property(propertiesComponent, AMQP_PASSWORD, 
null);
+
+            return new AMQPConnectionDetails("amqps://" + host + ":" + port, 
username,
+                                             password + 
"?transport.trustStoreLocation=" + TRUSTSTORE + 
"&transport.trustStorePassword=" + PASSWORD + "&transport.keyStoreLocation="
+                                                                               
        + KEYSTORE + "&transport.keyStorePassword=" + PASSWORD);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
     public String uri() {
         return uri;
     }
diff --git 
a/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPSSLRouteTest.java
 
b/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPSSLRouteTest.java
new file mode 100644
index 00000000000..93441402b32
--- /dev/null
+++ 
b/components/camel-amqp/src/test/java/org/apache/camel/component/amqp/AMQPSSLRouteTest.java
@@ -0,0 +1,167 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.amqp;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.SslContext;
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.impl.PropertyPlaceholderDelegateRegistry;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.qpid.jms.transports.TransportSslOptions;
+import org.apache.qpid.jms.transports.TransportSupport;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.camel.component.amqp.AMQPComponent.amqpComponent;
+import static org.apache.camel.component.amqp.AMQPConnectionDetails.AMQP_PORT;
+import static 
org.apache.camel.component.amqp.AMQPConnectionDetails.discoverAMQPSsl;
+
+
+public class AMQPSSLRouteTest extends CamelTestSupport {
+
+    static int amqpPort = AvailablePortFinder.getNextAvailable();
+    static BrokerService broker;
+
+    private static final String KEYSTORE = "./src/test/resources/broker.ks";
+    private static final String TRUSTSTORE = "./src/test/resources/broker.ks";
+    private static final String PASSWORD = "password";
+    
+
+    @EndpointInject(uri = "mock:result")
+    MockEndpoint resultEndpoint;
+
+    String expectedBody = "Hi there!";
+
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
+        System.setProperty("javax.net.ssl.trustStore", TRUSTSTORE);
+        System.setProperty("javax.net.ssl.keyStore", KEYSTORE);
+        System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);
+        System.setProperty(AMQP_PORT, amqpPort + "");
+
+        broker = new BrokerService();
+        broker.setPersistent(false);
+        broker.setAdvisorySupport(false);
+        broker.setDeleteAllMessagesOnStartup(true);
+        broker.setUseJmx(false);
+        broker.addConnector("amqp+ssl://0.0.0.0:" + amqpPort);
+
+        TransportSslOptions sslOptions = new TransportSslOptions();
+        sslOptions.setKeyStoreLocation(KEYSTORE);
+        sslOptions.setKeyStorePassword(PASSWORD);
+        sslOptions.setTrustStoreLocation(TRUSTSTORE);
+        sslOptions.setTrustStorePassword(PASSWORD);
+
+        SSLContext sslContext = TransportSupport.createSslContext(sslOptions);
+
+        final SslContext brokerContext = new SslContext();
+        brokerContext.setSSLContext(sslContext);
+
+        broker.setSslContext(brokerContext);
+        broker.start();
+
+    }
+
+    @AfterClass
+    public static void afterClass() throws Exception {
+        System.clearProperty("javax.net.ssl.trustStorePassword");
+        System.clearProperty("javax.net.ssl.trustStore");
+        System.clearProperty("javax.net.ssl.keyStore");
+        System.clearProperty("javax.net.ssl.keyStorePassword");
+        broker.stop();
+    }
+
+    @Test
+    public void testJmsQueue() throws Exception {
+        resultEndpoint.expectedMessageCount(1);
+        resultEndpoint.message(0).header("cheese").isEqualTo(123);
+        template.sendBodyAndHeader("amqp-ssl:queue:ping", expectedBody, 
"cheese", 123);
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    @Test
+    public void testRequestReply() {
+        String response = template.requestBody("amqp-ssl:queue:inOut", 
expectedBody, String.class);
+        assertEquals("response", response);
+    }
+
+    @Test
+    public void testJmsTopic() throws Exception {
+        resultEndpoint.expectedMessageCount(2);
+        resultEndpoint.message(0).header("cheese").isEqualTo(123);
+        template.sendBodyAndHeader("amqp-ssl:topic:ping", expectedBody, 
"cheese", 123);
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    @Test
+    public void testPrefixWildcard() throws Exception {
+        resultEndpoint.expectedMessageCount(1);
+        template.sendBody("amqp-ssl:wildcard.foo.bar", expectedBody);
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    @Test
+    public void testIncludeDestination() throws Exception {
+        resultEndpoint.expectedMessageCount(1);
+        resultEndpoint.message(0).header("JMSDestination").isEqualTo("ping");
+        template.sendBody("amqp-ssl:queue:ping", expectedBody);
+        resultEndpoint.assertIsSatisfied();
+    }
+    
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        return registry;
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        JndiRegistry registry = 
(JndiRegistry)((PropertyPlaceholderDelegateRegistry)camelContext.getRegistry()).getRegistry();
+        registry.bind("amqpConnection", discoverAMQPSsl(camelContext));        
+        camelContext.addComponent("amqp-ssl", 
amqpComponent("amqps://localhost:" + amqpPort));
+        return camelContext;
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                
from("amqp-ssl:queue:ping").to("log:routing").to("mock:result");
+
+                from("amqp-ssl:queue:inOut").setBody().constant("response");
+
+                
from("amqp-ssl:topic:ping").to("log:routing").to("mock:result");
+
+                
from("amqp-ssl:topic:ping").to("log:routing").to("mock:result");
+
+                
from("amqp-ssl:queue:wildcard.>").to("log:routing").to("mock:result");
+
+                
from("amqp:queue:uriEndpoint").to("log:routing").to("mock:result");
+            }
+        };
+    }
+
+}
diff --git a/components/camel-amqp/src/test/resources/broker.ks 
b/components/camel-amqp/src/test/resources/broker.ks
new file mode 100644
index 00000000000..86fe32c0411
Binary files /dev/null and b/components/camel-amqp/src/test/resources/broker.ks 
differ
diff --git a/components/camel-amqp/src/test/resources/broker_cert 
b/components/camel-amqp/src/test/resources/broker_cert
new file mode 100644
index 00000000000..80cbad5be0d
Binary files /dev/null and 
b/components/camel-amqp/src/test/resources/broker_cert differ
diff --git a/parent/pom.xml b/parent/pom.xml
index 5b57f0cfeb4..fea1680878a 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -563,9 +563,9 @@
     <protonpack-version>1.8</protonpack-version>
     <pubnub-version>4.6.5</pubnub-version>
     <qpid-bundle-version>0.28_1</qpid-bundle-version>
-    <qpid-proton-j-version>0.16.0</qpid-proton-j-version>
-    <qpid-proton-j-bundle-version>0.14.0</qpid-proton-j-bundle-version>
-    <qpid-jms-client-version>0.11.1</qpid-jms-client-version>
+    <qpid-proton-j-version>0.22.0</qpid-proton-j-version>
+    <qpid-proton-j-bundle-version>0.22.0</qpid-proton-j-bundle-version>
+    <qpid-jms-client-version>0.26.0</qpid-jms-client-version>
     <quartz-bundle-version>1.8.6_1</quartz-bundle-version>
     <quartz-version>1.8.6</quartz-version>
     <quartz-version-range>[1.8,2)</quartz-version-range>
@@ -762,7 +762,7 @@
       org.springframework.xml.*;version="[2,3)",
       org.springframework.*;version="${spring-version-range}",
       org.apache.cxf.*;version="${cxf-version-range}",
-      org.apache.qpid.*;version="[0.20,1)",
+      org.apache.qpid.*;version="[0.26,1)",
       org.apache.abdera.*;version="[0.4,2)",
       org.apache.commons.httpclient.*;version="[3.1,4.0)",
       org.apache.velocity.*;version="[1.6.2,2)",


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> camel-amqp - SSL Transport configuration
> ----------------------------------------
>
>                 Key: CAMEL-11780
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11780
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-amqp
>    Affects Versions: 2.19.2
>            Reporter: Cyril EDME
>            Assignee: Viral Gohel
>            Priority: Major
>             Fix For: 2.22.0
>
>
> Hi,
> i'm using camel and specially the amqp component to consume a topic. 
> Everything is working well but I'm confused regarding the SSL configuration.
> It's not clear in the documentation, I don't want to use the default JVM 
> certificate storage so I tried to configure the connection factory with the 
> [qpid 
> documentation|https://qpid.apache.org/releases/qpid-jms-0.24.0/docs/index.html#ssl-transport-configuration-options]
>  but the qpid-jms-client version used by amqp component (0.11.1) doesn't 
> handle the amqps schema URI.
> There is another way to configure the SSL transport like the key store 
> location and password without a qpid upgrade ?
> Thanks !



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to