I am using jersey-apache-client for a ssl connection.I am getting the handshake error at the time of verifying the connection. Below is the handshake error.
WRITE: TLSv1 Change Cipher Spec, length = 1
Finished
verify_data: { 165, 117, 49, 237, 116, 71, 111, 175, 161, 237, 45, 30 }
WRITE: TLSv1 Handshake, length = 48
READ: TLSv1 Alert, length = 2
RECV TLSv1 ALERT: fatal, handshake_failure
%% Invalidated: [Session-1, TLS_DHE_RSA_WITH_AES_128_CBC_SHA]
The code works fine if I use jersey-client-1.13 and I do not get a handshake error.
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(keyManagerFactory.getKeyManagers(), tmf.getTrustManagers(), null);
final ClientConfig config = new DefaultClientConfig();
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(null, ctx));
Client create = Client.create(config);
create.resource(targetUrl).post();
Since jersey-client.1.13 does not support proxy, I've used jersey-apache-client.1.18. In the below code I've used DefaultApacheHttpClientConfig, added proxy support,created client using ApacheHttpClient.
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(keyManagerFactory.getKeyManagers(), tmf.getTrustManagers(), null);
final DefaultApacheHttpClientConfig apacheConfig = new DefaultApacheHttpClientConfig();
final Map<String, Object> properties = apacheConfig.getProperties();
properties.put(DefaultApacheHttpClientConfig.PROPERTY_PROXY_URI, "http://" + proxyHost + ":" + proxyPort);
properties.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(null,ctx));
apacheConfig.getState().setProxyCredentials(AuthScope.ANY_REALM, proxyHost, Integer.parseInt(proxyPort),proxyUser, proxyPassword);
Client create = ApacheHttpClient.create(apacheConfig);
create.resource(targetUrl).post();
I could not find a solution. The certificates are all fine in both the cases.
Note: I have also tried the jersey apache client without proxy, still the error exists.
Do anyone find what went wrong? Thanks in advance.