Как настроить CXF в Spring Boot, если для параметра disableCNCheck установлено значение true в HttpConduit TLSClientParameters - PullRequest
0 голосов
/ 27 апреля 2018

Существует приложение Spring Boot, в котором используется компонент Camel cxf, объявленный в классе с аннотацией @Configuration и содержащий следующий код:

@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.
...