cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf git commit: CXF-7488 - "Protocol Mismatch when using Netty with TLS"
Date Tue, 29 Aug 2017 16:11:50 GMT
Repository: cxf
Updated Branches:
  refs/heads/master ca1fa2faa -> 12df8ab26


CXF-7488 - "Protocol Mismatch when using Netty with TLS"


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

Branch: refs/heads/master
Commit: 12df8ab265109473b406bba414efcd07bf94ebd6
Parents: ca1fa2f
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Aug 29 17:11:30 2017 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Aug 29 17:11:30 2017 +0100

----------------------------------------------------------------------
 .../http/netty/server/NettyHttpServerEngine.java   |  5 +++++
 .../netty/server/NettyHttpServerEngineTest.java    | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/12df8ab2/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
index b8547f6..deeee48 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
@@ -117,6 +117,11 @@ public class NettyHttpServerEngine implements ServerEngine {
      */
     public void setTlsServerParameters(TLSServerParameters params) {
         tlsServerParameters = params;
+        if (tlsServerParameters != null) {
+            protocol = "https";
+        } else {
+            protocol = "http";
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cxf/blob/12df8ab2/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineTest.java
b/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineTest.java
index c151a39..cd23ad9 100644
--- a/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineTest.java
+++ b/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineTest.java
@@ -25,8 +25,12 @@ import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.testutil.common.TestUtil;
 import org.easymock.EasyMock;
@@ -39,6 +43,8 @@ import org.junit.Test;
 public class NettyHttpServerEngineTest extends Assert {
     private static final int PORT1
         = Integer.valueOf(TestUtil.getPortNumber(NettyHttpServerEngineTest.class, 1));
+    private static final int PORT2
+        = Integer.valueOf(TestUtil.getPortNumber(NettyHttpServerEngineTest.class, 2));
     private static final int PORT3
         = Integer.valueOf(TestUtil.getPortNumber(NettyHttpServerEngineTest.class, 3));
 
@@ -140,6 +146,17 @@ public class NettyHttpServerEngineTest extends Assert {
         NettyHttpServerEngineFactory.destroyForPort(PORT3);
     }
 
+    @Test
+    public void testHttps() throws Exception {
+        Map<String, TLSServerParameters> tlsParamsMap = new HashMap<>();
+        tlsParamsMap.put(Integer.toString(PORT2), new TLSServerParameters());
+        factory.setTlsServerParameters(tlsParamsMap);
+
+        factory.createNettyHttpServerEngine(PORT2, "https");
+
+        NettyHttpServerEngineFactory.destroyForPort(PORT2);
+    }
+
     private String getResponse(String target) throws Exception {
         URL url = new URL(target);
 


Mime
View raw message