2014-11-06 53 views
0

我在做的时候无法生成密钥对DH的HTTP调用是这样的:了java.lang.RuntimeException:试图使调用Web服务

HttpPost httppost = new HttpPost(url); 
HttpClient httpclient = HttpClients.createDefault(); 

//ent is MultipartEntityBuilder ent 
httppost.setEntity(ent.build()); 
try { 
    HttpResponse response = httpclient.execute(httppost);**** 

我收到错误的代码与行****

javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair 
at sun.security.ssl.Alerts.getSSLException(Unknown Source) 
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) 
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) 
at sun.security.ssl.SSLSocketImpl.handleException(Unknown Source) 
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:279) 
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:257) 
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:132) 
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:349) 
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:365) 
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:221) 
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:199) 
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:87) 
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:109) 
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:84) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:109) 
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) 

我不太清楚是什么原因造成的。有人能告诉我这是什么原因吗?我正在拨打网络服务的其余呼叫

回答

0

看起来您会建立一个http连接并将其重定向到您未处理的https。您遇到SSL错误。它不能创建Diffie Hellman对,这是SSL握手的早期部分。

+0

如何处理此异常?我能够正常拨打电话 – 2014-11-06 03:22:08

+0

请确保url是http,而不是https。如果您正在自动重定向,那么您需要编写代码来处理SSL握手。 Google'SSL握手java' – CharlieS 2014-11-07 00:01:47