2015-08-28 476 views
3

從Carlo Scarioni的Pro Spring安全手冊中,我嘗試將Spring應用程序與CAS Server集成。我遵循本書指示的每一步,仍然陷入了這個錯誤。請幫助我。如果CAS服務器到CAS客戶端(JAR文件將表現爲客戶端)通信沒有發生,首先檢查網絡之類的東西兩個服務器,防火牆和端口阻塞之間的交流,如果每次都會出現PKIX路徑驗證失敗:java.security.cert.CertPathValidatorException:簽名檢查失敗

SEVERE: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: signature check failed 
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: signature check failed 
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) 
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1904) 
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:279) 
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:273) 
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1446) 
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:209) 
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:901) 
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:837) 
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1023) 
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343) 
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563) 
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301) 
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) 
    at org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:311) 
    at org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:291) 
    at org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator.retrieveResponseFromServer(AbstractCasProtocolUrlBasedTicketValidator.java:32) 
    at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:187) 
    at org.springframework.security.cas.authentication.CasAuthenticationProvider.authenticateNow(CasAuthenticationProvider.java:140) 
    at org.springframework.security.cas.authentication.CasAuthenticationProvider.authenticate(CasAuthenticationProvider.java:126) 
    at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156) 
    at org.springframework.security.cas.web.CasAuthenticationFilter.attemptAuthentication(CasAuthenticationFilter.java:242) 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:195) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) 
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) 
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336) 
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:483) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) 
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) 
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) 
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) 
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:412) 
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) 
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) 
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) 
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) 
    at org.eclipse.jetty.server.Server.handle(Server.java:351) 
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) 
    at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47) 
    at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) 
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) 
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634) 
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) 
    at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66) 
    at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254) 
    at org.eclipse.jetty.server.ssl.SslSocketConnector$SslConnectorEndPoint.run(SslSocketConnector.java:665) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: signature check failed 
    at sun.security.validator.PKIXValidator.doValidate(PKIXValidator.java:350) 
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:260) 
    at sun.security.validator.Validator.validate(Validator.java:260) 
    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326) 
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231) 
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126) 
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1428) 
    ... 55 more 
Caused by: java.security.cert.CertPathValidatorException: signature check failed 
    at sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:159) 
    at sun.security.provider.certpath.PKIXCertPathValidator.doValidate(PKIXCertPathValidator.java:347) 
    at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(PKIXCertPathValidator.java:191) 
    at java.security.cert.CertPathValidator.validate(CertPathValidator.java:279) 
    at sun.security.validator.PKIXValidator.doValidate(PKIXValidator.java:345) 
    ... 61 more 
Caused by: java.security.SignatureException: Signature does not match. 
    at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:451) 
    at sun.security.provider.certpath.BasicChecker.verifySignature(BasicChecker.java:160) 
    at sun.security.provider.certpath.BasicChecker.check(BasicChecker.java:139) 
    at sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:133) 
    ... 65 more 

2015-08-29 02:46:50.472:WARN:oejs.ServletHandler:/j_spring_cas_security_check 
java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: signature check failed 
    at org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:328) 
    at org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:291) 
    at org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator.retrieveResponseFromServer(AbstractCasProtocolUrlBasedTicketValidator.java:32) 
    at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:187) 
    at org.springframework.security.cas.authentication.CasAuthenticationProvider.authenticateNow(CasAuthenticationProvider.java:140) 
    at org.springframework.security.cas.authentication.CasAuthenticationProvider.authenticate(CasAuthenticationProvider.java:126) 
    at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156) 
    at org.springframework.security.cas.web.CasAuthenticationFilter.attemptAuthentication(CasAuthenticationFilter.java:242) 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:195) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) 
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) 
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336) 
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:483) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) 
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524) 
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) 
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) 
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:412) 
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) 
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) 
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) 
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) 
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149) 
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) 
    at org.eclipse.jetty.server.Server.handle(Server.java:351) 
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) 
    at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47) 
    at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) 
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) 
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634) 
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) 
    at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66) 
    at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254) 
    at org.eclipse.jetty.server.ssl.SslSocketConnector$SslConnectorEndPoint.run(SslSocketConnector.java:665) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599) 
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534) 
    at java.lang.Thread.run(Thread.java:745) 

回答

5

SSL握手例外事情是好的,那麼這個問題是因爲SSL證書,請確保在CAS服務器和客戶端(Spring安全應用程序)應用程序中使用相同的證書。

3

由於我還不能評論,我只會延伸到@卡邁勒的答案。我正在通過同一本書學習,但我使用Tomcat作爲區別,所以我不能給你同樣的答案,因爲我從來沒有使用過Jetty: 正如他所說的,你的SSL不能正常工作。證書未被瀏覽器和/或服務器接受,因此無法進行身份驗證,因此SSL握手會被拒絕。您需要確保您已將證書CAS.crt添加到您的JVM cacerts,正如他在本書(198-199)中所解釋的那樣,並檢查其是否正確。然後,您需要使用您使用的密碼將jetty-ssl.keystore添加到Jetty,以便它可以用於建立正確的連接。此外,您需要成爲,肯定確保它的本地主機名爲,因爲它不會起作用。這會根據你的環境而變化(生產,測試,只是學習......),但這是使它按照所描述的那樣工作的必要條件。 希望我在這裏不是太離譜,但我希望它有幫助。