2011-08-18 51 views
2

我正在編寫Java客戶端(在weblogic 10.3上)以調用安全的Web服務。 我已經提供了一個客戶證書,我已經安裝在cacerts,DemoIdentity.jks和DemoTrust,jks 在我的weblogic中,我已經設置了密鑰存儲DemoIdentity和DemoTrust。 在weblogic控制檯中,我設置了 「雙向客戶端證書行爲:」作爲「請求但未強制執行的客戶端證書」。 和「啓用SSL偵聽端口:」我已勾選複選框。已收到HANDSHAKE_FAILURE警報

我得到下面的異常試圖訪問該Web服務:

] FaultActor [null] Detail [<detail><bea_fault:stacktrace xmlns:bea_fault="http: 
//www.bea.com/servers/wls70/webservice/fault/1.0.0">javax.net.ssl.SSLHandshakeEx 
ception: [Security:090497]HANDSHAKE_FAILURE alert received from ************** Check both sides of the SSL configuration for mismatches in supported ciphers, supported protocol versions, trusted CAs, and hos 
tname verification settings. 
     at com.certicom.tls.interfaceimpl.TLSConnectionImpl.fireException(Unknow 
n Source) 
     at com.certicom.tls.interfaceimpl.TLSConnectionImpl.fireAlertReceived(Un 
known Source) 
     at com.certicom.tls.record.alert.AlertHandler.handle(Unknown Source) 
     at com.certicom.tls.record.alert.AlertHandler.handleAlertMessages(Unknow 
n Source) 
     at com.certicom.tls.record.MessageInterpreter.interpretContent(Unknown S 
ource) 
     at com.certicom.tls.record.MessageInterpreter.decryptMessage(Unknown Sou 
rce) 
     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(Unknow 
n Source) 
     at com.certicom.tls.interfaceimpl.TLSConnectionImpl.completeHandshake(Un 
known 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:65 
) 
     at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) 
     at java.io.FilterOutputStream.flush(FilterOutputStream.java:123) 
     at weblogic.net.http.HttpURLConnection.writeRequests(HttpURLConnection.j 
ava:158) 
     at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection. 
java:363) 
     at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLC 
onnection.java:37) 
     at weblogic.wsee.connection.transport.TransportUtil.getInputStream(Trans 
portUtil.java:85) 
     at weblogic.wsee.connection.transport.http.HTTPClientTransport.receive(H 
TTPClientTransport.java:271) 
     at weblogic.wsee.connection.soap.SoapConnection.receive(SoapConnection.j 
ava:485) 
     at weblogic.wsee.ws.dispatch.client.ConnectionHandler.handleResponse(Con 
nectionHandler.java:179) 
     at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator. 
java:287) 
     at weblogic.wsee.handler.HandlerIterator.handleResponse(HandlerIterator. 
java:271) 
     at weblogic.wsee.ws.dispatch.client.ClientDispatcher.handleResponse(Clie 
ntDispatcher.java:213) 
     at weblogic.wsee.ws.dispatch.client.ClientDispatcher.dispatch(ClientDisp 
atcher.java:150) 
     at weblogic.wsee.ws.WsStub.invoke(WsStub.java:87) 
     at weblogic.wsee.jaxrpc.StubImpl._invoke(StubImpl.java:339) 
     at sips_cn_contract.PaymentService_Stub.processPaymentWebInit(Unknown So 
urce) 
     at uk.gov.gateway.payments.SipsStartupController.handleRequest(SipsStart 
upController.java:73) 
     at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.ha 
ndle(SimpleControllerHandlerAdapter.java:45) 
     at org.springframework.web.servlet.DispatcherServlet.doService(Dispatche 
rServlet.java:485) 
     at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(Frame 
workServlet.java:342) 
     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServl 
et.java:318) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) 
     at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run 
(StubSecurityHelper.java:227) 
     at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri 
tyHelper.java:125) 
     at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav 
a:300) 
     at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav 
a:183) 
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio 
n.doIt(WebAppServletContext.java:3686) 
     at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio 
n.run(WebAppServletContext.java:3650) 
     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate 
dSubject.java:321) 
     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java: 
121) 
     at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS 
ervletContext.java:2268) 
     at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC 
ontext.java:2174) 
     at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j 
ava:1446) 
     at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) 
     at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) 
</bea_fault:stacktrace></detail>]; nested exception is: 

但是在Firefox中,我已經添加了證書,當我在網上查看service.It的WSDL促使我與證書和我點擊確定後,它呈現wsdl文件的安全Web服務。 任何人都知道我該怎麼做才能使客戶端使用Java?

回答

2

您可能未正確導入您的證書和密鑰。您可以通過添加以下到一個JUnit或類似測試您的密鑰庫:

static { 
     System.setProperty("javax.net.ssl.keyStoreType", "pkcs12"); // or whatever 
     System.setProperty("javax.net.ssl.keyStore", "c:/folder/mycert.p12"); 
     System.setProperty("javax.net.ssl.keyStorePassword", "mypassword"); 
     System.setProperty("javax.net.debug", "ssl"); 
} 

javax.net.debug屬性設置爲ssl將打印您的證書鏈和所有其他SSL記錄,這可能是有益的。您需要將證書等添加到您的應用程序容器中,就像您在生產中已有的一樣。

嘗試使用SSL進行調試,看看有什麼結果。很可能你只需要正確配置weblogic。檢查是否有自定義SSL端點配置(即,當URI是/ test/test使用keyStore XYZ時)。

+0

謝謝您的答覆。我已經在一個獨立的java類中分別測試了證書的東西。但是當我在weblogic上部署web應用程序時,它仍然給我帶來了同樣的異常。 – Priyanka

9

我認爲,真正的問題是,Weblogic的被不使用的JDK提供的標準太陽HTTPS實現,而是使用自己的,因爲顯然在這條線:

at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37) 

標準的Sun實現類被稱爲javax.net.ssl.HttpsURLConnection

因此,Weblogic內部的證書策略與獨立Java程序不同。我剛剛發現了這個調試類似的問題。

本頁面建議使用Sun實現的,而不是Weblogic的: http://webtech-kapil.blogspot.com/2010/06/javalangclasscastexception.html

他們建議用下列標誌啓動WL:

-DUseSunHttpHandler=true

將使用標準的Sun的SSL實現。不過,我個人還沒有嘗試過。

感謝,

伊戈爾

+0

我終於可以使用這個參數,並且可以確認它加載了SUN的實現並修復了這個問題。 – ipolevoy

相關問題