无法从 Weblogic 访问 HTTPS
Posted
技术标签:
【中文标题】无法从 Weblogic 访问 HTTPS【英文标题】:Cannot access HTTPS from Weblogic 【发布时间】:2015-03-11 18:20:09 【问题描述】:我在使用 Weblogic 访问 HTTPS 服务器时遇到问题,我可以访问其他 HTTPS 网址,例如 google 或 microsoft。 尝试连接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)
我尝试访问的服务器有一个经过验证的证书,浏览器不会抱怨它。
谢谢
【问题讨论】:
我不知道如何回答这个问题,但请尝试查看其他(已回答)SO 问题:***.com/questions/6353849/… 您不想使用Https
连接并在需要时设置证书吗? docs.oracle.com/cd/E11035_01/wls100/javadocs/weblogic/net/http/…
【参考方案1】:
对我来说,使用 -DUseSunHttpHandler=true
有效,但我不能使用此参数,因为这样我在重新部署时重新启动托管服务器时遇到问题。
这对我有帮助:
url = new URL(null,"https://yoururl.com",new sun.net.www.protocol.https.Handler());
【讨论】:
这将在 Eclipse 中在编译时失败,因为该类不能作为 Java API 访问。但是,如果需要,您可以通过反射间接使用它。【参考方案2】:最终它通过在 Weblogic 参数中设置这些来工作:
-DUseSunHttpHandler=true
-Dssl.SocketFactory.provider=sun.security.ssl.SSLSocketFactoryImpl
-Dssl.ServerSocketFactory.provider=sun.security.ssl.SSLSocketFactoryImpl
根据这些帖子:https://***.com/a/7276163 和 https://community.oracle.com/thread/2523332
【讨论】:
以上是关于无法从 Weblogic 访问 HTTPS的主要内容,如果未能解决你的问题,请参考以下文章
配置完weblogic后启动服务时提示“服务器与计算机相关联的节点管理器无法访问”是怎么回事呢?
weblogic10启动后无法登录控制台,输入登录名和密码后点登录后页面刷新了一下还在本页面,求解释
weblogic 工程发布完毕后,重启weblogic,无法进入控制台,启动框报错!
Weblogic集成服务器实例无法从jdeveloper启动