I'm trying to connect to a RESTful web service endpoint via HTTPS using WebSphere 5.1.
endpoint = new URL("https://restful/web/service");
HttpURLConnection connection = (HttpURLConnection) endpoint.openConnection();
connection.setRequestMethod("POST");
if (connection.getResponseCode() == 200) {
//Do something
} else {
//Show error
}
I am getting the following exception on getResponseCode()
[1/22/15 9:16:28:306 GMT] 9341a3d SystemErr R javax.net.ssl.SSLProtocolException: end of file
[1/22/15 9:16:28:306 GMT] 9341a3d SystemErr R at com.ibm.jsse.bg.a(Unknown Source)
[1/22/15 9:16:28:306 GMT] 9341a3d SystemErr R at com.ibm.jsse.bg.startHandshake(Unknown Source)
[1/22/15 9:16:28:306 GMT] 9341a3d SystemErr R at com.ibm.net.ssl.www.protocol.https.b.n(Unknown Source)
[1/22/15 9:16:28:306 GMT] 9341a3d SystemErr R at com.ibm.net.ssl.www.protocol.https.p.connect(Unknown Source)
[1/22/15 9:16:28:306 GMT] 9341a3d SystemErr R at com.ibm.net.ssl.www.protocol.http.bw.getInputStream(Unknown Source)
[1/22/15 9:16:28:307 GMT] 9341a3d SystemErr R at com.ibm.net.ssl.www.protocol.http.bw.getHeaderField(Unknown Source)
[1/22/15 9:16:28:307 GMT] 9341a3d SystemErr R at com.ibm.net.ssl.www.protocol.http.bw.getResponseCode(Unknown Source)
[1/22/15 9:16:28:307 GMT] 9341a3d SystemErr R at com.ibm.net.ssl.internal.www.protocol.https.HttpsURLConnection.getResponseCode(Unknown Source)
If I try the same code on WebLogic, it works fine. On top of that, for other endpoints (e.g. https://googleapis), it works perfectly on both WebLogic and WebSphere.
I have already imported the certificate to the truststore but it doesnt seem to have made a difference. Could someone advice on what the problem could be?
Found the solution finally. It appeared that Websphere was using SSLv3 by default for the SSL handshake instead of TLS. Forcing it to use TLS did the trick.
System.setProperty("https.protocols", "TLSv1");