You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/10/30 04:29:57 UTC

[camel] branch camel-2.x updated: CAMEL-14070 camel-netty4-http: update client to support Server Name Indication (SNI) Support (#3292)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.x by this push:
     new 7363259  CAMEL-14070 camel-netty4-http: update client to support Server Name Indication (SNI) Support (#3292)
7363259 is described below

commit 736325995c4e2fb254684b34f91bd5e795ba8f51
Author: Amos Feng <zf...@redhat.com>
AuthorDate: Wed Oct 30 12:29:49 2019 +0800

    CAMEL-14070 camel-netty4-http: update client to support Server Name Indication (SNI) Support (#3292)
---
 .../component/netty4/http/HttpClientInitializerFactory.java    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
index b5775a8..44e6e7c 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
@@ -16,11 +16,15 @@
  */
 package org.apache.camel.component.netty4.http;
 
+import java.net.URI;
+import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+import javax.net.ssl.SNIHostName;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLParameters;
 
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelHandler;
@@ -174,8 +178,12 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory {
         if (producer.getConfiguration().getSslHandler() != null) {
             return producer.getConfiguration().getSslHandler();
         } else if (sslContext != null) {
-            SSLEngine engine = sslContext.createSSLEngine();
+            URI uri = new URI(producer.getEndpoint().getEndpointUri());
+            SSLEngine engine = sslContext.createSSLEngine(uri.getHost(), uri.getPort());
             engine.setUseClientMode(true);
+            SSLParameters sslParameters = engine.getSSLParameters();
+            sslParameters.setServerNames(Arrays.asList(new SNIHostName(uri.getHost())));
+            engine.setSSLParameters(sslParameters);
             if (producer.getConfiguration().getSslContextParameters() == null) {
                 // just set the enabledProtocols if the SslContextParameter doesn't set
                 engine.setEnabledProtocols(producer.getConfiguration().getEnabledProtocols().split(","));