Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-20812

camel-netty-http: hostnameVerification option not used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 4.4.3, 4.7.0
    • camel-netty-http
    • None
    • Camel 3.x

      Java 11

    • Unknown

    Description

      I was trying to set query parameter hostnameVerification=true, in netty-http component, but it would not take effect.

      After some fault-finding it turns out that the implementation of hostnameVerification is in DefaultClientInitializerFactory (which is used by default in the netty component). However, in the netty-http component, HttpClientInitializerFactory is used by default, which does not use the hostnameVerification option.

      A workaround solution was to override HttpClientInitializerFactory:

      public class HttpsClientInitializerFactory extends HttpClientInitializerFactory {
      [constructors removed]
      
          @Override
          protected void initChannel(Channel ch) throws Exception {
              super.initChannel(ch);
              if (configuration.isHostnameVerification()) {
                  ChannelHandler handler = ch.pipeline().get("ssl");
                  SSLEngine engine = ((SslHandler)handler).engine();
                  SSLParameters sslParams = engine.getSSLParameters();
                  sslParams.setEndpointIdentificationAlgorithm("HTTPS");
                  engine.setSSLParameters(sslParams);
              }
          }
      }

      The hostnameVerification option is documented in both netty and netty-http components and it seems odd that it would require a custom ClientInitializerFactory.

      A possible solution would be to re-use the implementation from DefaultClientInitializerFactory in HttpClientInitializerFactory.

      Only tested in Camel 3.x but dont see any changes affecting this since implementation in CAMEL-16315

      Attachments

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              bjorpe Björn Pettersson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: