There is a Spring Boot application that use Camel cxf component declared in class annotaed with @Configuration and containing the next code:
@Bean
public CxfEndpoint cxfEndpoint() {
CxfEndpoint cxfEndpoint = new CxfEndpoint();
cxfEndpoint.setAddress(address);
cxfEndpoint.setWsdlURL(wsdlLocal);
cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
cxfEndpoint.setUsername(username);
cxfEndpoint.setPassword(password);
return cxfEndpoint;
}
How can HttpConduit be overwritten to set disableCNCheck to true?
Y tried this one with no success:
@Bean
public HTTPConduit http(SpringBus bus) {
// URL wsdl = getClass().getResource(wsdlLocal);
// ServiceClass service = new ServiceClass(wsdl);
// Interface interface = service.getPort(Interface.class);
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(ServiceClass.class);
factory.setAddress(address);
factory.setBus(bus);
Interface interface = factory.create(Interface.class);
Client client = ClientProxy.getClient(interface);
HTTPConduit http = (HTTPConduit) client.getConduit();
TLSClientParameters tls = new TLSClientParameters();
tls.setDisableCNCheck(true);
http.setTlsClientParameters(tls);
return http;
}
This is the exception:
Caused by: java.io.IOException: The https URL hostname does not match the Common Name (CN) on the server certificate in the client's truststore. Make sure server certificate is correct, or to disable this check (NOT recommended for production) set the CXF client TLS configuration property "disableCNCheck" to true.