Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 6.  Configuring Transport Security for Camel Components


Camel provides the Java Secure Socket Extension (JSSE) Utility API as a common way to configure Camel components to use Transport Layer Security (TLS). The main JSSE utility class is org.apache.util.jsse.SSLContextParameters. To configure TLS settings, you pass an instance of this class to a Camel component. You can configure an SSLContextParameters object by using pure Java or by using Spring or Blueprint XML.
The following code is an example of using Spring XML to configure an SSLContextParameters object:
<sslContextParameters id="sslContextParameters" xmlns="">
   <keyManagers keyPassword="secret1">
      <keyStore resource="./my_keystore.jks" password="secret2" />
      <keyStore resource="./my_truststore.jks" password="secret2" />
This shows the toplevel sslContextParameters element with keyManagers and trustManagers child elements. The keyManagers element configures the key store while the trustManagers element configures the trust store. For details about key stores and trust stores, see the Apache Camel documentation for the JSSE utility.
With this in place, you can reference the sslContextParameters bean in your endpoint URI. The following route runs a netty4 HTTPS endpoint. The ssl option is required. For example:
   <from uri="netty4:https://localhost:8080/early?sslContextParametersRef=#sslContextParameters&ssl=true"/>
The following code provides an example of how to configure transport security in Java:
protected JndiRegistry createRegistry() throws Exception {
   KeyStoreParameters ksp = new KeyStoreParameters();
   KeyManagersParameters kmp = new KeyManagersParameters();
   KeyStoreParameters tsp = new KeyStoreParameters();
   TrustManagersParameters tmp = new TrustManagersParameters();
   SSLContextParameters sslContextParameters = new SSLContextParameters();
   JndiRegistry registry = super.createRegistry();
   registry.bind("sslContextParameters", sslContextParameters);

   return registry;
The Java route for a netty4 HTTPS endpoint looks like the following. The ssl option is required.
In Camel, to call these HTTPS endpoints, also provide the sslContextParameters object that contains a trusted certificate. The following example reuses the server sslContextParameters object. In this example, the URI syntax is the same for the producer. For example:
String reply =       
            sslContextParameters", "Hi Camel!", String.class);
If you do not provide an sslContextParameters object that contains a valid trust store then the server does not allow a connection and Camel throws an execution exception - CamelExecutionException.