Camel Configuration UtilitiesPage edited by David ValeriChanges (5)
Full ContentJSSE UtilityThe JSSE Utility, available as of 2.8, allows you to easily configure aspects of the Java Secure Socket Extension (JSSE) API in order to greatly simplify the use of custom transport layer security (TLS) settings on Camel components. Supported ComponentsThe following Camel components directly support the use of this configuration utility: The following Camel components indirectly support the use of this configuration utility: ConfigurationThe key component in configuring TLS through the JSSE API is the SSLContext. The SSLContext provides socket factories for both client-side and server-side sockets as well as another component called an SSLEngine that is used by non-blocking IO to support TLS. The JSSE configuration utility provides an easy to use builder for configuring these JSSE components, among others, in a manner that allows you to provide all configuration options up front during the initialization of your application such that you don't have to customize library code or dig though the inner workings of a third-party library in order to inject hooks for the configuration of each component in the JSSE API. The central builder in the JSSE configuration utility is the SSLContextParameters. This class serves as the entry point for most configuration in the JSSE utility.
SSLContextParameters
KeyManagersParameters
TrustManagersParameters
KeyStoreParameters
FilterParameters
SecureRandomParameters
SSLContextServerParameters
SSLContextClientParameters
ExamplesProgrammatic UsageSetting Client Authentication On the Server SideThis configuration sets the server side aspects of the TLS configuration to require client authentication during the handshake process. This configuration uses the default trust store and a custom key store to provide key material for both the server and client sides of the SSLContext. KeyStoreParameters ksp = new KeyStoreParameters(); ksp.setResource("/users/home/server/keystore.jks"); ksp.setPassword("keystorePassword"); KeyManagersParameters kmp = new KeyManagersParameters(); kmp.setKeyStore(ksp); kmp.setKeyPassword("keyPassword"); SSLContextServerParameters scsp = new SSLContextServerParameters(); scsp.setClientAuthentication(ClientAuthentication.REQUIRE); SSLContextParameters scp = new SSLContextParameters(); scp.setServerParameters(scsp); scp.setKeyManagers(kmp); SSLContext context = scp.createSSLContext(); SSLEngine engine = scp.createSSLEngine(); Configuring Different Options on the Client and Server SideIn this example, both the client and server sides share the same custom key store; however, the client side allows any supported cipher suite while the server side will use the default cipher suite filter and exclude any cipher suites that match the patterns .*NULL.* and .*anon.*. KeyStoreParameters ksp = new KeyStoreParameters(); ksp.setResource("/users/home/server/keystore.jks"); ksp.setPassword("keystorePassword"); KeyManagersParameters kmp = new KeyManagersParameters(); kmp.setKeyStore(ksp); kmp.setKeyPassword("keyPassword"); FilterParameters filter = new FilterParameters(); filter.getInclude().add(".*"); SSLContextClientParameters sccp = new SSLContextClientParameters(); sccp.setCipherSuitesFilter(filter); SSLContextParameters scp = new SSLContextParameters(); scp.setClientParameters(sccp); scp.setKeyManagers(kmp); SSLContext context = scp.createSSLContext(); SSLEngine engine = scp.createSSLEngine(); Using Camel Property PlaceholdersThis configuration utility fully supports the use of property placeholders (see Using PropertyPlaceholder) in all configuration fields. In order to support this feature, the configuration utility objects must be configured with a reference to a Camel context. All of the utility classes except for CipherSuitesParameters and SecureSocketProtocolsParameters provide a setter method for providing the context reference. Do not confuse the lack of a setter on CipherSuitesParameters and SecureSocketProtocolsParameters as an indication that you cannot use property placeholders when configuring these classes. The lack of a setter is an internal implementation detail and full placeholder support is available for both of the configuration classes. In this example, both the client and server sides share the same custom key store; however, the client side allows any supported cipher suite while the server side will use the default cipher suite filter and exclude any cipher suites that match the patterns .*NULL.* and .*anon.*.KeyStoreParameters ksp = new KeyStoreParameters(); KeyManagersParameters kmp = new KeyManagersParameters(); FilterParameters filter = new FilterParameters(); SSLContextClientParameters sccp = new SSLContextClientParameters(); SSLContextParameters scp = new SSLContextParameters(); SSLContext context = scp.createSSLContext(); XML Configuration
Setting Client Authentication On the Server SideThis configuration sets the server side aspects of the TLS configuration to require client authentication during the handshake process. This configuration uses the default trust store and a custom key store to provide key material for both the server and client sides of the SSLContext. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <camel:sslContextParameters id="mySslContext"> <camel:keyManagers keyPassword="keyPassword"> <camel:keyStore resource="/users/home/server/keystore.jks" password="keystorePassword"/> </camel:keyManagers> <camel:serverParameters clientAuthentication="WANT"/> </camel:sslContextParameters> </beans> Configuring Different Options on the Client and Server SideIn this example, both the client and server sides share the same custom key store; however, the client side allows any supported cipher suite while the server side will use the default cipher suite filter and exclude any cipher suites that match the patterns .*NULL.* and .*anon.*. <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> xmlns:camel="http://camel.apache.org/schema/blueprint"> <camel:sslContextParameters id="mySslContext"> <camel:keyManagers keyPassword="keyPassword"> <camel:keyStore resource="/users/home/server/keystore.jks" password="keystorePassword"/> </camel:keyManagers> <camel:clientParameters> <camel:cipherSuitesFilter> <camel:include>.*</camel:include> </camel:cipherSuitesFilter> </camel:clientParameters> </camel:sslContextParameters> </blueprint>
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Camel > Camel Configuration Utilities confluence
- [CONF] Apache Camel > Camel Configuration Utilities confluence
- [CONF] Apache Camel > Camel Configuration Utilities confluence
- [CONF] Apache Camel > Camel Configuration Utilities confluence
- [CONF] Apache Camel > Camel Configuration Utilities confluence
- [CONF] Apache Camel > Camel Configuration Utilities confluence
- [CONF] Apache Camel > Camel Configuration Utilities confluence
- [CONF] Apache Camel > Camel Configuration Utilities confluence