3 Replies Latest reply on Feb 11, 2009 9:26 AM by janstey

    Camel and https

    brett_brettl

      I am trying to use the Jetty component to make a Camel endpoint that uses https. I looked at the Jetty component page on the Camel website and saw that you need to set System Properties for the keystore path (using jetty.ssl.keystore) and for the passwords (using jetty.ssl.keypassword and jetty.ssl.password). I did this and came up with the following example:

       

      public class ServerRoutes extends RouteBuilder {

       

          public void configure() throws Exception {

                

               System.setProperty("jetty.ssl.keystore", "/home/brett/workspace/Camel-https/keystore");

               System.setProperty("jetty.ssl.keypassword", "password1");

               System.setProperty("jetty.ssl.password", "password2");

       

              from("jetty:https://localhost:8443/security").

              process(new SecurityImpl()).to("file://received");

          }

      }

       

      When I try to run this I keep getting a file not found exception but the location it lists for the file is not the same as the one I specified in the System Property.

       

      ...

      2009-02-10 11:42:07.559::INFO:  jetty-6.1.14

      2009-02-10 11:42:07.592::WARN:  failed SslSocketConnector@localhost:8443

      java.io.FileNotFoundException: /home/brett/.keystore (No such file or directory)

              at java.io.FileInputStream.open(Native Method)

              at java.io.FileInputStream.(FileInputStream.java:106)

      ...

       

      Does anyone know why the Jetty component does not appear to be getting the correct path to the keystore file?

       

      Also I wrote this example using System.setProperty and DSL code. How would I write this in a Spring configuration file? I know the basic syntax for from and to, but how would I include the System Properties to indicate where the keystore is and what the passwords are? Thanks for any help.

       

      Brett

       

      Edited by: brett on Feb 10, 2009 4:59 PM

        • 1. Re: Camel and https
          janstey

          Not sure why the system properties are not working. What you have looks fine to me. Maybe try something like this?

           

          <bean id="jetty" class="org.apache.camel.component.jetty.JettyHttpComponent">
            <property name="sslPassword" value="password1"></property>
            <property name="sslKeyPassword" value="password2"></property>
            <property name="keystore" value="/home/brett/workspace/Camel-https/keystore"></property>
          </bean>  
            
          <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
            <route>
              <from uri="jetty:https://localhost:8443/security"></from>
              ...
            </route>
          </camelContext>
          

           

          • 2. Re: Camel and https
            brett_brettl

            I tired your solution but I got the following error:

             

            org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 149 in XML document from file /home/brett/workspace/Camel-https/target/classes/META-INF/spring/camel-server.xml is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'camelContext'.

             

            I went back and found that in your solution you listed the namespace for camelContext as http://camel.apache.org/schema/spring. I have seen other examples where the namespace is http://activemq.apache.org/camel/schema/spring. When I tried my camelContex like this:

             

             

             

            along with your suggested Jetty configuration everything worked fine. Thank you very much.

            • 3. Re: Camel and https
              janstey

              Oh, my bad. I was working from the trunk at Apache, in which the namespace changed recently.

               

              Glad you got it working and thanks for posting the solution.

               

              Cheers,

              Jon