Friday, 7 October 2016

Apache Camel - https Rest

Problem:

Hi Guys I have assigned an task on adding https for Rest in Apache Camel. I spent more time on this to get ti working , finally achieved. I thought of sharing with community  for easy to go.

Solution:


  1. We need to add SSL Context Parameters
  2. Add "CamelContextId" to SSLContextParameters Section.
  3. Add "Id" to SSLContextParameters which it later can be linked to where ever we need in the Camel Context defined.

   

 <sslcontextparameters camelcontextid="RestLab" id="sslContext_rest" xmlns="http://camel.apache.org/schema/spring">
  <keymanagers keypassword="keypassword">
   <keystore password="keystorePassword" resource="yourKeystore.jks">
   </keystore>
  </keymanagers>
  <serverparameters clientauthentication="WANT">
   <clientparameters>
    <ciphersuitesfilter>
     <include>.* </include>
    </ciphersuitesfilter>
   </clientparameters>
  </serverparameters>
 </sslcontextparameters>

 <camelcontext id="RestLab">
  <restconfiguration bindingmode="auto" component="restlet" enablecors="true" port="8080" scheme="https">

   <endpointproperty key="sslContextParameters" value="#sslContext_rest">
    <corsheaders key="Access-Control-Allow-Origin" value="*">
     <corsheaders key="Access-Control-Allow-Headers" value="Origin, Accept, X-Requested-With,
                                Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers">
      <corsheaders key="Access-Control-Allow-Methods" value="PUT,POST,GET,DELETE,OPTIONS">
      </corsheaders>
     </corsheaders>
    </corsheaders>
   </endpointproperty>
  </restconfiguration>
 </camelcontext>
 



No comments:

Post a Comment

Please comment here