WebSphere POST中的HTTPS POST请求在特定URL /证书中失败

时间:2015-01-22 09:27:50

标签: java https websphere jsse

我正在尝试使用WebSphere 5.1通过HTTPS连接到RESTful Web服务端点。

        endpoint                        = new URL("https://restful/web/service");

        HttpURLConnection connection    = (HttpURLConnection) endpoint.openConnection();
        connection.setRequestMethod("POST");

        if (connection.getResponseCode() == 200) {          
            //Do something
        } else {
            //Show error
        }

我在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)

如果我在WebLogic上尝试相同的代码,它可以正常工作。最重要的是,对于其他端点(例如https://googleapis),它在WebLogic和WebSphere上都能很好地工作。

我已经将证书导入到信任库,但它似乎没有什么区别。有人可以建议问题是什么吗?

1 个答案:

答案 0 :(得分:0)

最终找到解决方案。似乎Websphere默认使用SSLv3进行SSL握手而不是TLS。强迫它使用TLS就行了。

System.setProperty("https.protocols", "TLSv1");