有一个Spring Boot应用程序,它使用在@Effiguration注释的类中声明的Camel cxf组件并包含下一个代码:
@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;
}
如何覆盖HttpConduit以将disableCNCheck设置为true?
Y尝试过这个没有成功:
@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;
}
这是一个例外:
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.