Cannot access HTTPS from Weblogic

怎甘沉沦 提交于 2019-12-29 04:54:00

问题


I have a problem with Weblogic accessing an HTTPS server, I can access other HTTPS urls, like google or microsoft. The code that tries to connect to the url is:

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();

I get the following stack trace:

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)

In Weblogic's console I have the following setting set to true: Environment > Servers > [my server] > SSL > Advanced > Use JSSE SSL

If I disable that property I get the following stack trace:

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)

The server I try to access has a verified certificate and browsers don't complain about it.

Thanks


回答1:


Eventually it worked by setting these in the Weblogic arguments:

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

As per these posts: https://stackoverflow.com/a/7276163 and https://community.oracle.com/thread/2523332




回答2:


For me using -DUseSunHttpHandler=true works but I can't have this parameter, because then I have problems with restarting Managed Server on redeploy.

This helped me:

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


来源:https://stackoverflow.com/questions/27928157/cannot-access-https-from-weblogic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!