Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 68cf50f59 -> a6dcdf84d


CAMEL-10628: camel jetty9 endpoint configured with sslContextParametersRef and 
jetty handlers causes SSL handshake failure. Thanks to Joe Luo for the patch.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a6dcdf84
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a6dcdf84
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a6dcdf84

Branch: refs/heads/camel-2.18.x
Commit: a6dcdf84d20e28024ae774115f57b32bd73950ac
Parents: 68cf50f
Author: Andrea Cosentino <anco...@gmail.com>
Authored: Wed Dec 21 12:10:54 2016 +0100
Committer: Andrea Cosentino <anco...@gmail.com>
Committed: Wed Dec 21 12:10:54 2016 +0100

----------------------------------------------------------------------
 .../camel/component/jetty/JettyHttpComponent.java   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a6dcdf84/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
 
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 260e2bb..b89a90f 100644
--- 
a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ 
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -77,6 +77,7 @@ import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Response;
 import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.SslConnectionFactory;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 import org.eclipse.jetty.server.handler.ErrorHandler;
 import org.eclipse.jetty.server.handler.HandlerCollection;
@@ -346,8 +347,23 @@ public abstract class JettyHttpComponent extends 
HttpCommonComponent implements
                 
                 if (endpoint.getHandlers() != null && 
!endpoint.getHandlers().isEmpty()) {
                     // As the server is started, we need to stop the server 
for a while to add the new handler
+                    javax.net.ssl.SSLContext sct = null;
+                    SslConnectionFactory scf = null;
+                    // need to preserve SSLContext before the server is 
stopped since the SSLContext will be set to null
+                    if (endpoint.getSslContextParameters() != null) {
+                        scf = 
connectorRef.connector.getConnectionFactory(SslConnectionFactory.class);
+                        if (scf != null) {
+                            sct = scf.getSslContextFactory().getSslContext();
+                        }
+                    }
+
                     connectorRef.server.stop();
                     addJettyHandlers(connectorRef.server, 
endpoint.getHandlers());
+
+                    // reset SSLContext back before the server is restarted
+                    if (scf != null) {
+                        scf.getSslContextFactory().setSslContext(sct);
+                    }
                     connectorRef.server.start();
                 }
                 // ref track the connector

Reply via email to