无法从Weblogic访问HTTPS

时间:2015-01-13 17:39:45

标签: java ssl weblogic weblogic11g

Weblogic访问HTTPS服务器时遇到问题,我可以访问其他HTTPS网址,例如谷歌或微软。 尝试连接到URL的代码是:

URL url = new URL("https://myserver.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("User-Agent", "Mozilla/5.0");

// fails here
responseCode = connection.getResponseCode();

我得到以下堆栈跟踪:

java.io.IOException: Connection closed, EOF detected
    at weblogic.socket.JSSEFilterImpl.handleUnwrapResults(JSSEFilterImpl.java:539)
    at weblogic.socket.JSSEFilterImpl.unwrapAndHandleResults(JSSEFilterImpl.java:456)
    at weblogic.socket.JSSEFilterImpl.doHandshake(JSSEFilterImpl.java:80)
    at weblogic.socket.JSSEFilterImpl.doHandshake(JSSEFilterImpl.java:64)
    at weblogic.socket.JSSEFilterImpl.doHandshake(JSSEFilterImpl.java:59)
    at weblogic.socket.JSSEFilterImpl.write(JSSEFilterImpl.java:390)
    at weblogic.socket.JSSESocket$JSSEOutputStream.write(JSSESocket.java:78)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at java.io.FilterOutputStream.flush(FilterOutputStream.java:140)
    at weblogic.net.http.HttpURLConnection.writeRequests(HttpURLConnection.java:186)
    at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:400)
    at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
    at weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1005)

在Weblogic的控制台中,我将以下设置设置为true: 环境>服务器> [我的服务器]> SSL>高级>使用JSSE SSL

如果我禁用该属性,我会得到以下堆栈跟踪:

javax.net.ssl.SSLKeyException: FATAL Alert:BAD_CERTIFICATE - A corrupt or unuseable certificate was received.
    at com.certicom.tls.interfaceimpl.TLSConnectionImpl.fireException(Unknown Source)
    at com.certicom.tls.interfaceimpl.TLSConnectionImpl.fireAlertSent(Unknown Source)
    at com.certicom.tls.record.handshake.HandshakeHandler.fireAlert(Unknown Source)
    at com.certicom.tls.record.handshake.HandshakeHandler.handleHandshakeMessages(Unknown Source)
    at com.certicom.tls.record.MessageInterpreter.interpretContent(Unknown Source)
    at com.certicom.tls.record.MessageInterpreter.decryptMessage(Unknown Source)
    at com.certicom.tls.record.ReadHandler.processRecord(Unknown Source)
    at com.certicom.tls.record.ReadHandler.readRecord(Unknown Source)
    at com.certicom.tls.record.ReadHandler.readUntilHandshakeComplete(Unknown Source)
    at com.certicom.tls.interfaceimpl.TLSConnectionImpl.completeHandshake(Unknown Source)
    at com.certicom.tls.record.WriteHandler.write(Unknown Source)
    at com.certicom.io.OutputSSLIOStreamWrapper.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at java.io.FilterOutputStream.flush(FilterOutputStream.java:140)
    at weblogic.net.http.HttpURLConnection.writeRequests(HttpURLConnection.java:186)
    at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:400)
    at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
    at weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1005)

我尝试访问的服务器有经过验证的证书,浏览器不会抱怨它。

由于

2 个答案:

答案 0 :(得分:24)

最终它通过在Weblogic参数中设置它们来起作用:

-DUseSunHttpHandler=true 
-Dssl.SocketFactory.provider=sun.security.ssl.SSLSocketFactoryImpl 
-Dssl.ServerSocketFactory.provider=sun.security.ssl.SSLSocketFactoryImpl

根据这些帖子:https://stackoverflow.com/a/7276163https://community.oracle.com/thread/2523332

答案 1 :(得分:2)

对于我使用-DUseSunHttpHandler=true有效,但我不能使用此参数,因为我在重新部署时重新启动受管服务器时遇到问题。

这对我有所帮助:

url = new URL(null,"https://yoururl.com",new sun.net.www.protocol.https.Handler());