This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 47e61f63757b camel-http: endpoints of one component can use different
SSLContextParameters, and the JVM proxy properties need useSystemProperties
(#30081)
47e61f63757b is described below
commit 47e61f63757b7e7efdc30195bfb069172eec3169
Author: Federico Mariani <[email protected]>
AuthorDate: Sun Nov 15 19:05:58 2026 +0100
camel-http: endpoints of one component can use different
SSLContextParameters, and the JVM proxy properties need useSystemProperties
(#30081)
Co-authored-by: Claude <[email protected]>
---
.../org/apache/camel/catalog/components/http.json | 4 +-
.../org/apache/camel/catalog/components/https.json | 4 +-
.../apache/camel/catalog/docs/http-component.adoc | 102 ++++++++++++---------
.../org/apache/camel/component/http/http.json | 4 +-
.../org/apache/camel/component/http/https.json | 4 +-
.../camel-http/src/main/docs/http-component.adoc | 102 ++++++++++++---------
.../apache/camel/component/http/HttpComponent.java | 8 +-
.../apache/camel/component/http/HttpEndpoint.java | 9 +-
.../component/dsl/HttpComponentBuilderFactory.java | 7 +-
.../dsl/HttpsComponentBuilderFactory.java | 7 +-
.../endpoint/dsl/HttpEndpointBuilderFactory.java | 16 ++--
11 files changed, 147 insertions(+), 120 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/http.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/http.json
index 63a60fbf0fb5..5ba15d9f45ba 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/http.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/http.json
@@ -71,7 +71,7 @@
"proxyPort": { "index": 41, "kind": "property", "displayName": "Proxy
Port", "group": "proxy", "label": "producer,proxy", "required": false, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "description": "Proxy server port" },
"deserializationFilter": { "index": 42, "kind": "property", "displayName":
"Deserialization Filter", "group": "security", "label": "advanced,security",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description": "Sets
an ObjectInputFilter pattern (jdk.serialFilter syntax) applied when
deserializing Java objects from requests or responses with Content-Type
application\/x-java-serialized-object (only used [...]
"hostnameVerificationPolicy": { "index": 43, "kind": "property",
"displayName": "Hostname Verification Policy", "group": "security", "label":
"security", "required": false, "type": "enum", "javaType":
"org.apache.hc.client5.http.ssl.HostnameVerificationPolicy", "enum": [
"CLIENT", "BUILTIN", "BOTH" ], "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "CLIENT", "description": "Controls how
hostname verification is performed during the TLS handshake. CLIENT (def [...]
- "sslContextParameters": { "index": 44, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. Important: Only one instance of
org.apache.camel.support.jsse.SSLContextParameters is supported per
HttpComponent. If y [...]
+ "sslContextParameters": { "index": 44, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. An endpoint can use another instance with its own
sslContextParameters option." },
"useGlobalSslContextParameters": { "index": 45, "kind": "property",
"displayName": "Use Global Ssl Context Parameters", "group": "security",
"label": "security", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Enable usage of global SSL context
parameters." },
"x509HostnameVerifier": { "index": 46, "kind": "property", "displayName":
"X509 Hostname Verifier", "group": "security", "label": "security", "required":
false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier",
"deprecated": false, "autowired": false, "secret": false, "description": "To
use a custom X509HostnameVerifier such as DefaultHostnameVerifier or
NoopHostnameVerifier." },
"connectionRequestTimeout": { "index": 47, "kind": "property",
"displayName": "Connection Request Timeout", "group": "timeout", "label":
"timeout", "required": false, "type": "integer", "javaType": "long",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
180000, "description": "Returns the connection lease request timeout (in
millis) used when requesting a connection from the connection manager. A
timeout value of zero is interpreted as a disabled timeout." },
@@ -167,7 +167,7 @@
"oauth2ResourceIndicator": { "index": 64, "kind": "parameter",
"displayName": "Oauth2 Resource Indicator", "group": "security", "label":
"producer,security", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "OAuth2 Token endpoint" },
"oauth2Scope": { "index": 65, "kind": "parameter", "displayName": "Oauth2
Scope", "group": "security", "label": "producer,security", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "OAuth2 scope" },
"oauth2TokenEndpoint": { "index": 66, "kind": "parameter", "displayName":
"Oauth2 Token Endpoint", "group": "security", "label": "producer,security",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description":
"OAuth2 Resource Indicator" },
- "sslContextParameters": { "index": 67, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. Important: Only one instance of
org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent.
If you [...]
+ "sslContextParameters": { "index": 67, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. This takes precedence over the sslContextParameters
of the component, so endpoints of the same component can use diffe [...]
"x509HostnameVerifier": { "index": 68, "kind": "parameter", "displayName":
"X509 Hostname Verifier", "group": "security", "label": "security", "required":
false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier",
"deprecated": false, "autowired": false, "secret": false, "security":
"insecure:ssl", "description": "To use a custom X509HostnameVerifier such as
DefaultHostnameVerifier or NoopHostnameVerifier" },
"oauth2CachedTokensKeyResolver": { "index": 69, "kind": "parameter",
"displayName": "Oauth2 Cached Tokens Key Resolver", "group": "security
(advanced)", "label": "producer,security,advanced", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.http.OAuth2CachedTokensKeyResolver", "deprecated":
false, "autowired": false, "secret": false, "description": "To use a custom
strategy to compute the key of cached OAuth2 tokens when oauth2CacheTokens is
enabled. When [...]
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/https.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/https.json
index 690929256fe2..9280f47dd985 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/https.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/https.json
@@ -71,7 +71,7 @@
"proxyPort": { "index": 41, "kind": "property", "displayName": "Proxy
Port", "group": "proxy", "label": "producer,proxy", "required": false, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "description": "Proxy server port" },
"deserializationFilter": { "index": 42, "kind": "property", "displayName":
"Deserialization Filter", "group": "security", "label": "advanced,security",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description": "Sets
an ObjectInputFilter pattern (jdk.serialFilter syntax) applied when
deserializing Java objects from requests or responses with Content-Type
application\/x-java-serialized-object (only used [...]
"hostnameVerificationPolicy": { "index": 43, "kind": "property",
"displayName": "Hostname Verification Policy", "group": "security", "label":
"security", "required": false, "type": "enum", "javaType":
"org.apache.hc.client5.http.ssl.HostnameVerificationPolicy", "enum": [
"CLIENT", "BUILTIN", "BOTH" ], "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "CLIENT", "description": "Controls how
hostname verification is performed during the TLS handshake. CLIENT (def [...]
- "sslContextParameters": { "index": 44, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. Important: Only one instance of
org.apache.camel.support.jsse.SSLContextParameters is supported per
HttpComponent. If y [...]
+ "sslContextParameters": { "index": 44, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. An endpoint can use another instance with its own
sslContextParameters option." },
"useGlobalSslContextParameters": { "index": 45, "kind": "property",
"displayName": "Use Global Ssl Context Parameters", "group": "security",
"label": "security", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Enable usage of global SSL context
parameters." },
"x509HostnameVerifier": { "index": 46, "kind": "property", "displayName":
"X509 Hostname Verifier", "group": "security", "label": "security", "required":
false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier",
"deprecated": false, "autowired": false, "secret": false, "description": "To
use a custom X509HostnameVerifier such as DefaultHostnameVerifier or
NoopHostnameVerifier." },
"connectionRequestTimeout": { "index": 47, "kind": "property",
"displayName": "Connection Request Timeout", "group": "timeout", "label":
"timeout", "required": false, "type": "integer", "javaType": "long",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
180000, "description": "Returns the connection lease request timeout (in
millis) used when requesting a connection from the connection manager. A
timeout value of zero is interpreted as a disabled timeout." },
@@ -167,7 +167,7 @@
"oauth2ResourceIndicator": { "index": 64, "kind": "parameter",
"displayName": "Oauth2 Resource Indicator", "group": "security", "label":
"producer,security", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "OAuth2 Token endpoint" },
"oauth2Scope": { "index": 65, "kind": "parameter", "displayName": "Oauth2
Scope", "group": "security", "label": "producer,security", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "OAuth2 scope" },
"oauth2TokenEndpoint": { "index": 66, "kind": "parameter", "displayName":
"Oauth2 Token Endpoint", "group": "security", "label": "producer,security",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description":
"OAuth2 Resource Indicator" },
- "sslContextParameters": { "index": 67, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. Important: Only one instance of
org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent.
If you [...]
+ "sslContextParameters": { "index": 67, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. This takes precedence over the sslContextParameters
of the component, so endpoints of the same component can use diffe [...]
"x509HostnameVerifier": { "index": 68, "kind": "parameter", "displayName":
"X509 Hostname Verifier", "group": "security", "label": "security", "required":
false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier",
"deprecated": false, "autowired": false, "secret": false, "security":
"insecure:ssl", "description": "To use a custom X509HostnameVerifier such as
DefaultHostnameVerifier or NoopHostnameVerifier" },
"oauth2CachedTokensKeyResolver": { "index": 69, "kind": "parameter",
"displayName": "Oauth2 Cached Tokens Key Resolver", "group": "security
(advanced)", "label": "producer,security,advanced", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.http.OAuth2CachedTokensKeyResolver", "deprecated":
false, "autowired": false, "secret": false, "description": "To use a custom
strategy to compute the key of cached OAuth2 tokens when oauth2CacheTokens is
enabled. When [...]
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/http-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/http-component.adoc
index 7a39232673f5..0b58a0d04d6a 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/http-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/http-component.adoc
@@ -165,7 +165,7 @@ HTTP response headers as well to the _OUT_ message headers.
=== Using System Properties
-When setting useSystemProperties to true, the HTTP Client will look for
+When setting `useSystemProperties` to `true`, the HTTP Client will look for
the following System Properties, and it will use it:
* `ssl.TrustManagerFactory.algorithm`
@@ -181,9 +181,20 @@ the following System Properties, and it will use it:
* `javax.net.ssl.keyStorePassword`
* `http.proxyHost`
* `http.proxyPort`
+* `https.proxyHost`
+* `https.proxyPort`
* `http.nonProxyHosts`
* `http.keepAlive`
-* `http.maxConnections`
+
+The `http.proxyHost` and `http.proxyPort` properties apply to `http` targets
only. For `https` targets, set
+`https.proxyHost` and `https.proxyPort`.
+
+Without `useSystemProperties`, the HTTP Client does not read these properties,
with one exception: it uses the default
+trust store of the JVM, so the `javax.net.ssl.trustStore` properties apply
unless `sslContextParameters` is set.
+
+You can set `useSystemProperties` on the endpoint, or on the component for all
its endpoints, such as with
+`camel.component.http.use-system-properties=true`. The `https` component is
configured on its own, such as with
+`camel.component.https.use-system-properties=true`.
=== Response code
@@ -586,9 +597,10 @@ Spring XML
</camelContext>
----
-Camel will first set the settings from Java System or CamelContext
-Properties and then the endpoint proxy options if provided.
-So you can override the system properties with the endpoint options.
+Camel uses these global options only when `useSystemProperties` is `false`,
the default. The JVM system properties,
+such as `http.proxyHost`, are only used with `useSystemProperties=true`, see
+<<_using_system_properties,Using System Properties>>. The proxy options of the
endpoint or the component, such as
+`proxyAuthHost` and `proxyAuthPort`, take precedence over both.
There is also a `http.proxyScheme` property you
can set to explicitly configure the scheme to use.
@@ -964,23 +976,10 @@ class. +
`org.apache.camel.component.http.HttpClientConfigurer` to do some
configuration on the http client if you need full control of it.
-However, if you _just_ want to specify the keystore and truststore, you
-can do this with Apache HTTP `HttpClientConfigurer`, for example:
-
-._Java-only: programmatic `KeyStore` and `SchemeRegistry` setup_
-[source,java]
-----
-KeyStore keystore = ...;
-KeyStore truststore = ...;
-
-SchemeRegistry registry = new SchemeRegistry();
-registry.register(new Scheme("https", 443, new SSLSocketFactory(keystore,
"mypassword", truststore)));
-----
-
-And then you need to create a class that implements
-`HttpClientConfigurer`, and registers https protocol providing a
-keystore or truststore per the example above. Then, from your camel route
-builder class, you can hook it up like so:
+However, if you _just_ want to specify the keystore and truststore, use
+`sslContextParameters` as shown above. If you implement an
+`HttpClientConfigurer`, you can hook it up from your camel route builder
+class like so:
._Java-only: programmatic `HttpClientConfigurer` setup_
[source,java]
@@ -1002,9 +1001,6 @@ If you are doing this using the Spring DSL, you can
specify your
<to
uri="https://myhostname.com:443/myURL?httpClientConfigurer=#myHttpClientConfigurer"/>
----
-As long as you implement the `HttpClientConfigurer` and configure your
-keystore and truststore as described above, it will work fine.
-
[[HTTP-UsingHTTPStoauthenticategotchas]]
Using HTTPS to authenticate gotchas
@@ -1065,26 +1061,50 @@ public class HttpContextFactory {
[[HTTP-UsingdifferentSSLContextParameters]]
Using different SSLContextParameters
-The xref:http-component.adoc[HTTP] component only supports one instance of
-`org.apache.camel.support.jsse.SSLContextParameters` per component. If you
-need to use two or more different instances, then you need to set up
-multiple xref:http-component.adoc[HTTP] components as shown below. Where we
have
-two components, each using their own instance of `sslContextParameters`
-property.
+The `sslContextParameters` option of an endpoint takes precedence over the one
of the component. So endpoints of the
+same component can use different `SSLContextParameters` instances, and you do
not need a component per instance. A
+dynamic endpoint can refer to one as well:
-._XML-only: Spring bean declarations for multiple HTTP components with
different SSL contexts_
-[source,xml]
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:start")
+ .toD("https://${header.host}/orders?sslContextParameters=#mySSL");
----
-<bean id="http-foo" class="org.apache.camel.component.http.HttpComponent">
- <property name="sslContextParameters" ref="sslContextParams1"/>
- <property name="x509HostnameVerifier" ref="hostnameVerifier"/>
-</bean>
-<bean id="http-bar" class="org.apache.camel.component.http.HttpComponent">
- <property name="sslContextParameters" ref="sslContextParams2"/>
- <property name="x509HostnameVerifier" ref="hostnameVerifier"/>
-</bean>
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct:start
+ steps:
+ - toD:
+ uri: "https://${header.host}/orders?sslContextParameters=#mySSL"
----
+====
+
+To define `mySSL` in XML or YAML, see
+xref:manual::camel-configuration-utilities.adoc#_configuring_sslcontextparameters_in_xml_and_yaml_dsl[JSSE
Utility].
+
+With Camel Main, the `camel.ssl.*` properties set up global
`SSLContextParameters` instead. An `https` endpoint uses
+them when the `https` component has `useGlobalSslContextParameters=true`, and
neither the endpoint nor the component
+sets `sslContextParameters`:
+
+[source,properties]
+----
+camel.ssl.enabled=true
+camel.ssl.trust-store=truststore.p12
+camel.ssl.trust-store-password=changeit
+camel.component.https.use-global-ssl-context-parameters=true
+----
+
+When the component or the endpoint has a `clientConnectionManager`, Camel uses
that connection manager as it is, and
+`sslContextParameters` is not applied.
== Removing http protocol headers in the Camel Message
diff --git
a/components/camel-http/src/generated/resources/META-INF/org/apache/camel/component/http/http.json
b/components/camel-http/src/generated/resources/META-INF/org/apache/camel/component/http/http.json
index 63a60fbf0fb5..5ba15d9f45ba 100644
---
a/components/camel-http/src/generated/resources/META-INF/org/apache/camel/component/http/http.json
+++
b/components/camel-http/src/generated/resources/META-INF/org/apache/camel/component/http/http.json
@@ -71,7 +71,7 @@
"proxyPort": { "index": 41, "kind": "property", "displayName": "Proxy
Port", "group": "proxy", "label": "producer,proxy", "required": false, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "description": "Proxy server port" },
"deserializationFilter": { "index": 42, "kind": "property", "displayName":
"Deserialization Filter", "group": "security", "label": "advanced,security",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description": "Sets
an ObjectInputFilter pattern (jdk.serialFilter syntax) applied when
deserializing Java objects from requests or responses with Content-Type
application\/x-java-serialized-object (only used [...]
"hostnameVerificationPolicy": { "index": 43, "kind": "property",
"displayName": "Hostname Verification Policy", "group": "security", "label":
"security", "required": false, "type": "enum", "javaType":
"org.apache.hc.client5.http.ssl.HostnameVerificationPolicy", "enum": [
"CLIENT", "BUILTIN", "BOTH" ], "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "CLIENT", "description": "Controls how
hostname verification is performed during the TLS handshake. CLIENT (def [...]
- "sslContextParameters": { "index": 44, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. Important: Only one instance of
org.apache.camel.support.jsse.SSLContextParameters is supported per
HttpComponent. If y [...]
+ "sslContextParameters": { "index": 44, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. An endpoint can use another instance with its own
sslContextParameters option." },
"useGlobalSslContextParameters": { "index": 45, "kind": "property",
"displayName": "Use Global Ssl Context Parameters", "group": "security",
"label": "security", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Enable usage of global SSL context
parameters." },
"x509HostnameVerifier": { "index": 46, "kind": "property", "displayName":
"X509 Hostname Verifier", "group": "security", "label": "security", "required":
false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier",
"deprecated": false, "autowired": false, "secret": false, "description": "To
use a custom X509HostnameVerifier such as DefaultHostnameVerifier or
NoopHostnameVerifier." },
"connectionRequestTimeout": { "index": 47, "kind": "property",
"displayName": "Connection Request Timeout", "group": "timeout", "label":
"timeout", "required": false, "type": "integer", "javaType": "long",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
180000, "description": "Returns the connection lease request timeout (in
millis) used when requesting a connection from the connection manager. A
timeout value of zero is interpreted as a disabled timeout." },
@@ -167,7 +167,7 @@
"oauth2ResourceIndicator": { "index": 64, "kind": "parameter",
"displayName": "Oauth2 Resource Indicator", "group": "security", "label":
"producer,security", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "OAuth2 Token endpoint" },
"oauth2Scope": { "index": 65, "kind": "parameter", "displayName": "Oauth2
Scope", "group": "security", "label": "producer,security", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "OAuth2 scope" },
"oauth2TokenEndpoint": { "index": 66, "kind": "parameter", "displayName":
"Oauth2 Token Endpoint", "group": "security", "label": "producer,security",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description":
"OAuth2 Resource Indicator" },
- "sslContextParameters": { "index": 67, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. Important: Only one instance of
org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent.
If you [...]
+ "sslContextParameters": { "index": 67, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. This takes precedence over the sslContextParameters
of the component, so endpoints of the same component can use diffe [...]
"x509HostnameVerifier": { "index": 68, "kind": "parameter", "displayName":
"X509 Hostname Verifier", "group": "security", "label": "security", "required":
false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier",
"deprecated": false, "autowired": false, "secret": false, "security":
"insecure:ssl", "description": "To use a custom X509HostnameVerifier such as
DefaultHostnameVerifier or NoopHostnameVerifier" },
"oauth2CachedTokensKeyResolver": { "index": 69, "kind": "parameter",
"displayName": "Oauth2 Cached Tokens Key Resolver", "group": "security
(advanced)", "label": "producer,security,advanced", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.http.OAuth2CachedTokensKeyResolver", "deprecated":
false, "autowired": false, "secret": false, "description": "To use a custom
strategy to compute the key of cached OAuth2 tokens when oauth2CacheTokens is
enabled. When [...]
}
diff --git
a/components/camel-http/src/generated/resources/META-INF/org/apache/camel/component/http/https.json
b/components/camel-http/src/generated/resources/META-INF/org/apache/camel/component/http/https.json
index 690929256fe2..9280f47dd985 100644
---
a/components/camel-http/src/generated/resources/META-INF/org/apache/camel/component/http/https.json
+++
b/components/camel-http/src/generated/resources/META-INF/org/apache/camel/component/http/https.json
@@ -71,7 +71,7 @@
"proxyPort": { "index": 41, "kind": "property", "displayName": "Proxy
Port", "group": "proxy", "label": "producer,proxy", "required": false, "type":
"integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired":
false, "secret": false, "description": "Proxy server port" },
"deserializationFilter": { "index": 42, "kind": "property", "displayName":
"Deserialization Filter", "group": "security", "label": "advanced,security",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description": "Sets
an ObjectInputFilter pattern (jdk.serialFilter syntax) applied when
deserializing Java objects from requests or responses with Content-Type
application\/x-java-serialized-object (only used [...]
"hostnameVerificationPolicy": { "index": 43, "kind": "property",
"displayName": "Hostname Verification Policy", "group": "security", "label":
"security", "required": false, "type": "enum", "javaType":
"org.apache.hc.client5.http.ssl.HostnameVerificationPolicy", "enum": [
"CLIENT", "BUILTIN", "BOTH" ], "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "CLIENT", "description": "Controls how
hostname verification is performed during the TLS handshake. CLIENT (def [...]
- "sslContextParameters": { "index": 44, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. Important: Only one instance of
org.apache.camel.support.jsse.SSLContextParameters is supported per
HttpComponent. If y [...]
+ "sslContextParameters": { "index": 44, "kind": "property", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. An endpoint can use another instance with its own
sslContextParameters option." },
"useGlobalSslContextParameters": { "index": 45, "kind": "property",
"displayName": "Use Global Ssl Context Parameters", "group": "security",
"label": "security", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Enable usage of global SSL context
parameters." },
"x509HostnameVerifier": { "index": 46, "kind": "property", "displayName":
"X509 Hostname Verifier", "group": "security", "label": "security", "required":
false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier",
"deprecated": false, "autowired": false, "secret": false, "description": "To
use a custom X509HostnameVerifier such as DefaultHostnameVerifier or
NoopHostnameVerifier." },
"connectionRequestTimeout": { "index": 47, "kind": "property",
"displayName": "Connection Request Timeout", "group": "timeout", "label":
"timeout", "required": false, "type": "integer", "javaType": "long",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
180000, "description": "Returns the connection lease request timeout (in
millis) used when requesting a connection from the connection manager. A
timeout value of zero is interpreted as a disabled timeout." },
@@ -167,7 +167,7 @@
"oauth2ResourceIndicator": { "index": 64, "kind": "parameter",
"displayName": "Oauth2 Resource Indicator", "group": "security", "label":
"producer,security", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "OAuth2 Token endpoint" },
"oauth2Scope": { "index": 65, "kind": "parameter", "displayName": "Oauth2
Scope", "group": "security", "label": "producer,security", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "OAuth2 scope" },
"oauth2TokenEndpoint": { "index": 66, "kind": "parameter", "displayName":
"Oauth2 Token Endpoint", "group": "security", "label": "producer,security",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "description":
"OAuth2 Resource Indicator" },
- "sslContextParameters": { "index": 67, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. Important: Only one instance of
org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent.
If you [...]
+ "sslContextParameters": { "index": 67, "kind": "parameter", "displayName":
"Ssl Context Parameters", "group": "security", "label": "security", "required":
false, "type": "object", "javaType":
"org.apache.camel.support.jsse.SSLContextParameters", "deprecated": false,
"autowired": false, "secret": false, "description": "To configure security
using SSLContextParameters. This takes precedence over the sslContextParameters
of the component, so endpoints of the same component can use diffe [...]
"x509HostnameVerifier": { "index": 68, "kind": "parameter", "displayName":
"X509 Hostname Verifier", "group": "security", "label": "security", "required":
false, "type": "object", "javaType": "javax.net.ssl.HostnameVerifier",
"deprecated": false, "autowired": false, "secret": false, "security":
"insecure:ssl", "description": "To use a custom X509HostnameVerifier such as
DefaultHostnameVerifier or NoopHostnameVerifier" },
"oauth2CachedTokensKeyResolver": { "index": 69, "kind": "parameter",
"displayName": "Oauth2 Cached Tokens Key Resolver", "group": "security
(advanced)", "label": "producer,security,advanced", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.http.OAuth2CachedTokensKeyResolver", "deprecated":
false, "autowired": false, "secret": false, "description": "To use a custom
strategy to compute the key of cached OAuth2 tokens when oauth2CacheTokens is
enabled. When [...]
}
diff --git a/components/camel-http/src/main/docs/http-component.adoc
b/components/camel-http/src/main/docs/http-component.adoc
index 7a39232673f5..0b58a0d04d6a 100644
--- a/components/camel-http/src/main/docs/http-component.adoc
+++ b/components/camel-http/src/main/docs/http-component.adoc
@@ -165,7 +165,7 @@ HTTP response headers as well to the _OUT_ message headers.
=== Using System Properties
-When setting useSystemProperties to true, the HTTP Client will look for
+When setting `useSystemProperties` to `true`, the HTTP Client will look for
the following System Properties, and it will use it:
* `ssl.TrustManagerFactory.algorithm`
@@ -181,9 +181,20 @@ the following System Properties, and it will use it:
* `javax.net.ssl.keyStorePassword`
* `http.proxyHost`
* `http.proxyPort`
+* `https.proxyHost`
+* `https.proxyPort`
* `http.nonProxyHosts`
* `http.keepAlive`
-* `http.maxConnections`
+
+The `http.proxyHost` and `http.proxyPort` properties apply to `http` targets
only. For `https` targets, set
+`https.proxyHost` and `https.proxyPort`.
+
+Without `useSystemProperties`, the HTTP Client does not read these properties,
with one exception: it uses the default
+trust store of the JVM, so the `javax.net.ssl.trustStore` properties apply
unless `sslContextParameters` is set.
+
+You can set `useSystemProperties` on the endpoint, or on the component for all
its endpoints, such as with
+`camel.component.http.use-system-properties=true`. The `https` component is
configured on its own, such as with
+`camel.component.https.use-system-properties=true`.
=== Response code
@@ -586,9 +597,10 @@ Spring XML
</camelContext>
----
-Camel will first set the settings from Java System or CamelContext
-Properties and then the endpoint proxy options if provided.
-So you can override the system properties with the endpoint options.
+Camel uses these global options only when `useSystemProperties` is `false`,
the default. The JVM system properties,
+such as `http.proxyHost`, are only used with `useSystemProperties=true`, see
+<<_using_system_properties,Using System Properties>>. The proxy options of the
endpoint or the component, such as
+`proxyAuthHost` and `proxyAuthPort`, take precedence over both.
There is also a `http.proxyScheme` property you
can set to explicitly configure the scheme to use.
@@ -964,23 +976,10 @@ class. +
`org.apache.camel.component.http.HttpClientConfigurer` to do some
configuration on the http client if you need full control of it.
-However, if you _just_ want to specify the keystore and truststore, you
-can do this with Apache HTTP `HttpClientConfigurer`, for example:
-
-._Java-only: programmatic `KeyStore` and `SchemeRegistry` setup_
-[source,java]
-----
-KeyStore keystore = ...;
-KeyStore truststore = ...;
-
-SchemeRegistry registry = new SchemeRegistry();
-registry.register(new Scheme("https", 443, new SSLSocketFactory(keystore,
"mypassword", truststore)));
-----
-
-And then you need to create a class that implements
-`HttpClientConfigurer`, and registers https protocol providing a
-keystore or truststore per the example above. Then, from your camel route
-builder class, you can hook it up like so:
+However, if you _just_ want to specify the keystore and truststore, use
+`sslContextParameters` as shown above. If you implement an
+`HttpClientConfigurer`, you can hook it up from your camel route builder
+class like so:
._Java-only: programmatic `HttpClientConfigurer` setup_
[source,java]
@@ -1002,9 +1001,6 @@ If you are doing this using the Spring DSL, you can
specify your
<to
uri="https://myhostname.com:443/myURL?httpClientConfigurer=#myHttpClientConfigurer"/>
----
-As long as you implement the `HttpClientConfigurer` and configure your
-keystore and truststore as described above, it will work fine.
-
[[HTTP-UsingHTTPStoauthenticategotchas]]
Using HTTPS to authenticate gotchas
@@ -1065,26 +1061,50 @@ public class HttpContextFactory {
[[HTTP-UsingdifferentSSLContextParameters]]
Using different SSLContextParameters
-The xref:http-component.adoc[HTTP] component only supports one instance of
-`org.apache.camel.support.jsse.SSLContextParameters` per component. If you
-need to use two or more different instances, then you need to set up
-multiple xref:http-component.adoc[HTTP] components as shown below. Where we
have
-two components, each using their own instance of `sslContextParameters`
-property.
+The `sslContextParameters` option of an endpoint takes precedence over the one
of the component. So endpoints of the
+same component can use different `SSLContextParameters` instances, and you do
not need a component per instance. A
+dynamic endpoint can refer to one as well:
-._XML-only: Spring bean declarations for multiple HTTP components with
different SSL contexts_
-[source,xml]
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:start")
+ .toD("https://${header.host}/orders?sslContextParameters=#mySSL");
----
-<bean id="http-foo" class="org.apache.camel.component.http.HttpComponent">
- <property name="sslContextParameters" ref="sslContextParams1"/>
- <property name="x509HostnameVerifier" ref="hostnameVerifier"/>
-</bean>
-<bean id="http-bar" class="org.apache.camel.component.http.HttpComponent">
- <property name="sslContextParameters" ref="sslContextParams2"/>
- <property name="x509HostnameVerifier" ref="hostnameVerifier"/>
-</bean>
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct:start
+ steps:
+ - toD:
+ uri: "https://${header.host}/orders?sslContextParameters=#mySSL"
----
+====
+
+To define `mySSL` in XML or YAML, see
+xref:manual::camel-configuration-utilities.adoc#_configuring_sslcontextparameters_in_xml_and_yaml_dsl[JSSE
Utility].
+
+With Camel Main, the `camel.ssl.*` properties set up global
`SSLContextParameters` instead. An `https` endpoint uses
+them when the `https` component has `useGlobalSslContextParameters=true`, and
neither the endpoint nor the component
+sets `sslContextParameters`:
+
+[source,properties]
+----
+camel.ssl.enabled=true
+camel.ssl.trust-store=truststore.p12
+camel.ssl.trust-store-password=changeit
+camel.component.https.use-global-ssl-context-parameters=true
+----
+
+When the component or the endpoint has a `clientConnectionManager`, Camel uses
that connection manager as it is, and
+`sslContextParameters` is not applied.
== Removing http protocol headers in the Camel Message
diff --git
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
index 9ca7ed29d561..534a21c3481a 100644
---
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
+++
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
@@ -97,8 +97,7 @@ public class HttpComponent extends HttpCommonComponent
implements RestProducerFa
description = "To use a custom
org.apache.hc.core5.http.protocol.HttpContext when executing requests.")
protected HttpContext httpContext;
@Metadata(label = "security", description = "To configure security using
SSLContextParameters."
- + " Important: Only one
instance of org.apache.camel.support.jsse.SSLContextParameters is supported per
HttpComponent."
- + " If you need to use 2 or
more different instances, you need to define a new HttpComponent per instance
you need.")
+ + " An endpoint can use
another instance with its own sslContextParameters option.")
protected SSLContextParameters sslContextParameters;
@Metadata(label = "security",
description = "To use a custom X509HostnameVerifier such as
DefaultHostnameVerifier or NoopHostnameVerifier.")
@@ -839,9 +838,8 @@ public class HttpComponent extends HttpCommonComponent
implements RestProducerFa
}
/**
- * To configure security using SSLContextParameters. Important: Only one
instance of
- * org.apache.camel.support.jsse.SSLContextParameters is supported per
HttpComponent. If you need to use two or more
- * different instances, you need to define a new HttpComponent per
instance.
+ * To configure security using SSLContextParameters. An endpoint can use
another instance with its own
+ * sslContextParameters option.
*/
public void setSslContextParameters(SSLContextParameters
sslContextParameters) {
this.sslContextParameters = sslContextParameters;
diff --git
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
index 334bf81faaa1..a4655a50417b 100644
---
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
+++
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
@@ -94,8 +94,8 @@ public class HttpEndpoint extends HttpCommonEndpoint
implements LineNumberAware
private String location;
@UriParam(label = "security", description = "To configure security using
SSLContextParameters."
- + " Important: Only one
instance of org.apache.camel.util.jsse.SSLContextParameters is supported per
HttpComponent."
- + " If you need to use 2 or
more different instances, you need to define a new HttpComponent per instance
you need.")
+ + " This takes precedence over
the sslContextParameters of the component,"
+ + " so endpoints of the same
component can use different instances.")
protected SSLContextParameters sslContextParameters;
@UriParam(label = "advanced", description = "To use a custom HttpContext
instance")
@@ -638,9 +638,8 @@ public class HttpEndpoint extends HttpCommonEndpoint
implements LineNumberAware
}
/**
- * To configure security using SSLContextParameters. Important: Only one
instance of
- * org.apache.camel.util.jsse.SSLContextParameters is supported per
HttpComponent. If you need to use 2 or more
- * different instances, you need to define a new HttpComponent per
instance you need.
+ * To configure security using SSLContextParameters. This takes precedence
over the sslContextParameters of the
+ * component, so endpoints of the same component can use different
instances.
*/
public void setSslContextParameters(SSLContextParameters
sslContextParameters) {
this.sslContextParameters = sslContextParameters;
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HttpComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HttpComponentBuilderFactory.java
index e415ff390d01..a0bb2bb0b857 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HttpComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HttpComponentBuilderFactory.java
@@ -837,11 +837,8 @@ public interface HttpComponentBuilderFactory {
}
/**
- * To configure security using SSLContextParameters. Important: Only
one
- * instance of org.apache.camel.support.jsse.SSLContextParameters is
- * supported per HttpComponent. If you need to use 2 or more different
- * instances, you need to define a new HttpComponent per instance you
- * need.
+ * To configure security using SSLContextParameters. An endpoint can
use
+ * another instance with its own sslContextParameters option.
*
* The option is a:
*
<code>org.apache.camel.support.jsse.SSLContextParameters</code>
type.
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HttpsComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HttpsComponentBuilderFactory.java
index 08f9a6cca5b9..cf244182cff8 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HttpsComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HttpsComponentBuilderFactory.java
@@ -837,11 +837,8 @@ public interface HttpsComponentBuilderFactory {
}
/**
- * To configure security using SSLContextParameters. Important: Only
one
- * instance of org.apache.camel.support.jsse.SSLContextParameters is
- * supported per HttpComponent. If you need to use 2 or more different
- * instances, you need to define a new HttpComponent per instance you
- * need.
+ * To configure security using SSLContextParameters. An endpoint can
use
+ * another instance with its own sslContextParameters option.
*
* The option is a:
*
<code>org.apache.camel.support.jsse.SSLContextParameters</code>
type.
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HttpEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HttpEndpointBuilderFactory.java
index dd5594a72e3e..e24188870f04 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HttpEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/HttpEndpointBuilderFactory.java
@@ -1034,11 +1034,9 @@ public interface HttpEndpointBuilderFactory {
return this;
}
/**
- * To configure security using SSLContextParameters. Important: Only
one
- * instance of org.apache.camel.util.jsse.SSLContextParameters is
- * supported per HttpComponent. If you need to use 2 or more different
- * instances, you need to define a new HttpComponent per instance you
- * need.
+ * To configure security using SSLContextParameters. This takes
+ * precedence over the sslContextParameters of the component, so
+ * endpoints of the same component can use different instances.
*
* The option is a:
* <code>org.apache.camel.support.jsse.SSLContextParameters</code>
type.
@@ -1053,11 +1051,9 @@ public interface HttpEndpointBuilderFactory {
return this;
}
/**
- * To configure security using SSLContextParameters. Important: Only
one
- * instance of org.apache.camel.util.jsse.SSLContextParameters is
- * supported per HttpComponent. If you need to use 2 or more different
- * instances, you need to define a new HttpComponent per instance you
- * need.
+ * To configure security using SSLContextParameters. This takes
+ * precedence over the sslContextParameters of the component, so
+ * endpoints of the same component can use different instances.
*
* The option will be converted to a
* <code>org.apache.camel.support.jsse.SSLContextParameters</code>
type.