我正在尝试使用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();
我得到了这个例外:
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)
使用curl对同一台计算机上相同网址的请求正常工作 - 如果我将网址更改为例如https://www.verisign.com,它在Java中运行良好。所以它似乎是Java和主机的特定组合,而不是一般问题。
Ubuntu 10.04 beta,Sun JDK 1.6.0_19(在Ubuntu捆绑的OpenJDK 6b18~pre4中也出现同样的问题。)
任何想法出了什么问题?谢谢!
答案 0 :(得分:5)
我们有一个webstart应用程序因此问题而失败。添加:
时,命令行版本再次起作用java.lang.System.setProperty(“sun.security.ssl.allowUnsafeRenegotiation”,“true”);
但是webstart版本似乎忽略了这一点,直到现在我们还没有办法在webstart版本中设置这个属性。
答案 1 :(得分:2)
至少该解决方案也适用于此问题:添加“-Dsun.security.ssl.allowUnsafeRenegotiation = true”
非常感谢你! 我试图通过SSL连接使用maven部署,使用证书,我有同样的例外。现在它解决了。再次感谢!
答案 2 :(得分:1)
与此处相同的问题,我认为:http://forums.sun.com/thread.jspa?threadID=5435426
至少该解决方案也适用于此问题:添加“-Dsun.security.ssl.allowUnsafeRenegotiation = true”
答案 3 :(得分:1)
只是为此添加一些更新 - Oracle has this KB that discusses the problem。
我们在Windows 7上遇到了JRE 1.6.0_20,但升级到1.6.0_25已经解决了问题(我意识到有更新的版本,但是为了软件测试的利益,我们正在测试范围版本 - 这是我们最早能够完成的。)