I am trying to communicating with another https URL by using "HttpClient API" method. But I am getting the below exception:
SSLHandshakeException: Received fatal alert: handshake_failure
JDK 1.7
Server: Wildfly 9
I have imported the certificate into the key store as well
Java code
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.MultipartPostMethod;
import org.apache.commons.httpclient.protocol.Protocol;
class SSLTest {
public static void main(String args[]) {
String responseString = "";
String sslStr = "https";
String urlString ="https://<urlString>/Registration?Param1=test";
HttpClient client = new HttpClient();
if(sslStr.equals("https")){
try{
Protocol httpsProtocol = new Protocol( "https", new EasySSLProtocolSocketFactory(), serverPort);
Protocol.registerProtocol("https", httpsProtocol);
client.getHostConfiguration().setHost(serverip, serverPort,httpsProtocol);
}catch(Exception e2){
System.out.println("Fail to create certificate :"+e2.getMessage());
}
}
MultipartPostMethod mPost = new MultipartPostMethod(urlString);
client.setConnectionTimeout(1000*3*60);
try{
int statusCode = client.executeMethod(mPost);
}catch(Exception e2){
System.out.println("Exception: "+e2.getMessage());
}
responseString = mPost.getResponseBodyAsString();
mPost.releaseConnection();
System.out.println("responseString = " + responseString);
}
}
-------
Output
-------
Exception: Received fatal alert: handshake_failure
responseString = NULL
Expected output: It should reach the specified URL Server. But here, unable to communicate with the server.
Thanks in advance.