Cannot access HTTPS from Weblogic
Asked Answered
Z

2

6

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

Zuniga answered 13/1, 2015 at 17:39 Comment(2)
I don't know enough to answer this, but try looking at this other (answered) SO question: #6354349Dael
Don't you want to use a Https connection instead and set the certs if they are needed? docs.oracle.com/cd/E11035_01/wls100/javadocs/weblogic/net/http/…Connett
Z
25

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

Zuniga answered 13/1, 2015 at 21:27 Comment(0)
D
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());
Deflective answered 8/11, 2016 at 8:1 Comment(1)
This will fail in Eclipse at compile time, due to that class not being accessible as a Java API. However, you can use it indirectly via reflection if necessary.Vermination

© 2022 - 2024 — McMap. All rights reserved.