[
https://issues.apache.org/jira/browse/CXF-8326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17179033#comment-17179033
]
Alain Sellerin commented on CXF-8326:
-------------------------------------
I removed some details and made a few changes to make it shorter but the
client code is this one:
{noformat}
String KeyManagerAlgorithm = "SunX509";
String SSLVersion = "TLSv1";
SSLContext sslcontext = null;
KeyManagerFactory kmf = null ;
try {
sslcontext = SSLContext.getInstance(SSLVersion);
kmf = KeyManagerFactory.getInstance(KeyManagerAlgorithm);
KeyStore ks = KeyStore.getInstance(KeyStoreType);
ks.load(RnetConnect.class.getClassLoader().getResourceAsStream(keystore),
keyStorePassword.toCharArray());
kmf.init(ks, keyStorePassword.toCharArray());
TrustManagerFactory tmf =
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ks);
} catch (Exception e) {
e.printStackTrace();
}
try {
sslcontext.init(kmf.getKeyManagers(), null, null);
} catch (KeyManagementException e) {
log.error("Error while init on TrustManager: ", e);
}
URL wsdlURL = RnetConnect.class.getClassLoader().getResource("Get.wsdl");
QName SERVICE_NAME = new QName("http://example.service.com", "GetService");
javax.xml.ws.Service service = GetService.create(wsdlURL, SERVICE_NAME);
Get port1 = service.getPort(Get.class);
Map<String, Object> ctx = ((BindingProvider)port1).getRequestContext();
Client client = ClientProxy.getClient(port1);
Endpoint cxfEndpoint = client.getEndpoint();
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(3000);
httpClientPolicy.setAllowChunking(false);
http.setClient(httpClientPolicy);
TLSClientParameters tlsClientParameters = new TLSClientParameters();
tlsClientParameters.setSSLSocketFactory(sslcontext.getSocketFactory());
http.setTlsClientParameters(tlsClientParameters);
((BindingProvider)port1).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"https://myservice/Get");
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(ctx);
cxfEndpoint.getOutInterceptors().add(wssOut);
GetRequest req = new GetRequest();
String response = port1.getGet(req);
{noformat}
> SSLContext protocol version is ignored
> --------------------------------------
>
> Key: CXF-8326
> URL: https://issues.apache.org/jira/browse/CXF-8326
> Project: CXF
> Issue Type: Bug
> Components: Transports
> Affects Versions: 3.1.4
> Reporter: Alain Sellerin
> Priority: Major
>
> Hi,
> I'm doing a migration from CXF 2.4.6 to 3.1.4
>
> This code is working perfectly fine in 2.4.6:
> {noformat}
> SSLContext sslcontext = SSLContext.getInstance("TLSv1");
> ...
> TLSClientParameters tlsClientParameters = new TLSClientParameters();
> tlsClientParameters.setSSLSocketFactory(sslcontext.getSocketFactory());
> http.setTlsClientParameters(tlsClientParameters);{noformat}
> The ssl protocol version is respected when making the call (i-e TLSv1)
> With SSLContext.getInstance("TLSv1.1") the call is made with TLSv1.1
> With SSLContext.getInstance("TLSv1.2") the call is made with TLSv1.2
> All is fine.
>
> However, in 3.1.4, no matter the provided tls version it will always be
> TLSv1.2. The provided ssl version in SSLContext.getInstance("TLSv1") is just
> ignored.
> I checked with 3.2.7 and 2.7.18. It is failing as well.
>
> Thank you in advance for checking it.
> Regards
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)