Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
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
- links to