Java SSLException: HelloRequest 后跟意外的握手消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2606873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SSLException: HelloRequest followed by an unexpected handshake message
提问by mseebach
I'm trying to connect to a webservice over SSL using Apache Commons HttpClient 3.1, using this:
我正在尝试使用 Apache Commons HttpClient 3.1 通过 SSL 连接到 Web 服务,使用以下命令:
String url = "https://archprod.service.eogs.dk/cvronline/esb/LegalUnitGetSSLServicePort";
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(url);
StringRequestEntity entity = new StringRequestEntity(requestXml, "application/soap+xml", "utf-8");
post.setRequestEntity(entity);
client.executeMethod(post);
String response = post.getResponseBodyAsString();
And I get this exception:
我得到这个例外:
javax.net.ssl.SSLException: HelloRequest followed by an unexpected handshake message
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1623)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:198)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:188)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloRequest(ClientHandshaker.java:286)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:114)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:525)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:465)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:746)
at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
A request to the same URL on the same machine, using curl, works fine - and if I change the URL to e.g. https://www.verisign.com, it works fine in Java, too. So it appears to be the specific combination of Java and that host, not a general problem.
使用 curl 在同一台机器上请求相同的 URL 可以正常工作 - 如果我将 URL 更改为例如https://www.verisign.com,它在 Java 中也可以正常工作。所以它似乎是Java和那个主机的特定组合,而不是一个普遍的问题。
Ubuntu 10.04 beta, Sun JDK 1.6.0_19 (same problem in Ubuntu's bundled OpenJDK 6b18~pre4).
Ubuntu 10.04 beta,Sun JDK 1.6.0_19(Ubuntu 捆绑的 OpenJDK 6b18~pre4 中存在相同问题)。
Any ideas what's going wrong? Thanks!
任何想法出了什么问题?谢谢!
采纳答案by mseebach
Same issue as here, I think: http://forums.sun.com/thread.jspa?threadID=5435426
与此处相同的问题,我认为:http: //forums.sun.com/thread.jspa?threadID=5435426
At least the solution works for this issue, too: add "-Dsun.security.ssl.allowUnsafeRenegotiation=true"
至少该解决方案也适用于此问题:添加“-Dsun.security.ssl.allowUnsafeRenegotiation=true”
回答by BartH
We have a webstart application which fails because of this issue. The command-line version is working again when adding :
我们有一个 webstart 应用程序由于这个问题而失败。添加时命令行版本再次运行:
java.lang.System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
java.lang.System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
But the webstart version seems to ignore this, and until now we haven't foud a way to set this property in the webstart version.
但是 webstart 版本似乎忽略了这一点,直到现在我们还没有办法在 webstart 版本中设置这个属性。
回答by Dave
At least the solution works for this issue, too: add "-Dsun.security.ssl.allowUnsafeRenegotiation=true"
至少该解决方案也适用于此问题:添加“-Dsun.security.ssl.allowUnsafeRenegotiation=true”
Thank you very very very much for that! I was trying to use maven deploy through an SSL connection, using certificates and I had the same exception. Now it is solved. Thanks again!
非常非常非常感谢!我试图通过 SSL 连接使用 maven 部署,使用证书,但我有同样的例外。现在它解决了。再次感谢!
回答by Chris J
Just to add some updates to this - Oracle has this KB that discusses the problem.
只是为此添加一些更新 - Oracle有此 KB 讨论了该问题。
We've come across with with JRE 1.6.0_20 on Windows 7, but upgrading to 1.6.0_25 has resovled the problem (I realise there are later versions, however in the interests of software testing we're testing with a range of versions - this is the earliest we've been able to lay our hands on).
我们在 Windows 7 上遇到过 JRE 1.6.0_20,但是升级到 1.6.0_25 已经解决了这个问题(我意识到还有更高版本,但是为了软件测试的利益,我们正在测试一系列版本 -这是我们最早能够接触到的)。