2013-08-01 137 views
1

當我的客戶端應用程序嘗試從我的安全休息Web服務請求資源時,出現下面粘貼的錯誤。澤西客戶端握手錯誤

我在主題上找到了這個答案,但額外的代碼看起來極端。 Accessing secure restful web services using jersey client 有誰知道解決這個問題的更簡單方法嗎?

我的項目: 在服務器端,我正在使用jdbc領域的基本認證,在瀏覽器中使用時工作正常。在客戶端,我設置了用戶名和密碼,並在發送請求時發生錯誤。 如果您需要代碼片段,請詢問。 謝謝你的時間。

Aug 01, 2013 7:00:09 PM com.sun.jersey.api.client.filter.LoggingFilter log 
INFO: 1 * Client out-bound request 
1 > GET https://localhost:8080/HelloWorld/resources/helloWorld 
1 > Accept: text/html 
1 > Authorization: Basic ZGF2aWQ6bXVycmF5 

Exception in thread "AWT-EventQueue-0" com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake 
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) 
    at com.sun.jersey.api.client.filter.LoggingFilter.handle(LoggingFilter.java:183) 
    at com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java:81) 
    at com.sun.jersey.api.client.Client.handle(Client.java:648) 
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:670) 
    at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) 
    at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:503) 
    at secure_rest_hello_client.rest_secure_client.getXml(rest_secure_client.java:42) 
    at secure_rest_hello_client.test_client.jButton1ActionPerformed(test_client.java:72) 
    at secure_rest_hello_client.test_client.access$000(test_client.java:11) 
    at secure_rest_hello_client.test_client$1.actionPerformed(test_client.java:39) 
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) 
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) 
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 
    at java.awt.Component.processMouseEvent(Component.java:6505) 
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) 
    at java.awt.Component.processEvent(Component.java:6270) 
    at java.awt.Container.processEvent(Container.java:2229) 
    at java.awt.Component.dispatchEventImpl(Component.java:4861) 
    at java.awt.Container.dispatchEventImpl(Container.java:2287) 
    at java.awt.Component.dispatchEvent(Component.java:4687) 
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) 
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) 
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) 
    at java.awt.Container.dispatchEventImpl(Container.java:2273) 
    at java.awt.Window.dispatchEventImpl(Window.java:2713) 
    at java.awt.Component.dispatchEvent(Component.java:4687) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707) 
    at java.awt.EventQueue.access$000(EventQueue.java:101) 
    at java.awt.EventQueue$3.run(EventQueue.java:666) 
    at java.awt.EventQueue$3.run(EventQueue.java:664) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) 
    at java.awt.EventQueue$4.run(EventQueue.java:680) 
    at java.awt.EventQueue$4.run(EventQueue.java:678) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:677) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) 
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) 
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake 
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:912) 
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1294) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1321) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1305) 
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:523) 
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1296) 
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) 
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) 
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:240) 
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:147) 
    ... 46 more 
Caused by: java.io.EOFException: SSL peer shut down incorrectly 
    at sun.security.ssl.InputRecord.read(InputRecord.java:352) 
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:893) 
    ... 56 more 
+0

發現問題,是使用http而不是https。 – David031

回答

0

您的SSL連接根本沒有設置。用於設置SSL 連接的握手過程失敗。如果您在https監聽器端口 *上執行非SSL請求(http),則可能發生以下情況: *如果服務器配置了未完成的安全檢查(例如客戶端證書) *其他協商問題 大多數情況下這些問題可以用curl或openssl命令行客戶端來檢查。只有事情起作用。使用curl和/或openssl你可能想看看你的代碼問題(你沒有在你的問題中顯示)