Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7488

Protocol Mismatch when using Netty with TLS

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.12
    • Fix Version/s: 3.1.13, 3.2.0
    • Component/s: Transports
    • Labels:
      None
    • Environment:

      Windows 7, JDK 1.8.0_144

    • Estimated Complexity:
      Unknown

      Description

      I'm using the classes NettyHttpServerEngineFactory and NettyHttpServerEngine to configure a server with TLS using only Java code (without Spring or other XML configurations). Therefore I constructed the necessary TLSServerParameters and created an engine factory:

      TLSServerParameters tlsParams = new TLSServerParameters();
      tlsParams.setKeyManagers(km);
      tlsParams.setTrustManagers(tm);
      tlsParams.setCipherSuitesFilter(filter);
      tlsParams.setClientAuthentication(ca);
      NettyHttpServerEngineFactory factory = new NettyHttpServerEngineFactory(sf.getBus());
      Map<String, TLSServerParameters> tlsParamsMap = new HashMap<>();
      tlsParamsMap.put(Integer.toString(port), tlsParams);
      factory.setTlsServerParameters(tlsParamsMap);
      

      Where sf is an object of JaxWsServerFactoryBean and I previously initialized all the necessary KeyManagers etc.
      Afterwards I want to create an engine using the factory:

      NettyHttpServerEngine engine = localFactory.createNettyHttpServerEngine(port, "https");
      

      Afterwards I get the following Exception:

      java.io.IOException: Protocol mismatch for port 4816: engine's protocol is http, the url protocol is https
      	at org.apache.cxf.transport.http.netty.server.NettyHttpServerEngineFactory.createNettyHttpServerEngine(NettyHttpServerEngineFactory.java:184)
      	at org.apache.cxf.transport.http.netty.server.NettyHttpServerEngineFactory.createNettyHttpServerEngine(NettyHttpServerEngineFactory.java:194)
      

      When looking at the (really similar) class JettyHTTPServerEngineFactory there is a method retrieveListenerFactory called in methods setTlsServerParameters and finalizeConfig which changes the protocol of the engine to https when tls parameters are provided, in NettyHttpServerEngineFactory it doesn't exist so far and the finalizeConfig method is empty.

      Could you provide something similar to used code in JettyHTTPServerEngineFactory aswell in NettyHttpServerEngineFactory as it would solve my problems perfectly.

      Let me know if I need to provide any other informations/code.

        Attachments

          Activity

            People

            • Assignee:
              coheigea Colm O hEigeartaigh
              Reporter:
              lars.kaulen Lars Kaulen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: