2015-05-20 25 views
7

Tôi gặp lỗi khi giải mã mã thông báo saml. Tuy nhiên vấn đề này là không phù hợp nó hoạt động sau khi khởi động lại máy chủ. Nó được làm việc đúng cách cho đến đêm qua :(Nhận lỗi khi giải mã mã thông báo Saml

DEBUG Decrypter:631 - Attempt to decrypt EncryptedKey using credential from KEK KeyInfo resolver failed: 
     org.opensaml.xml.encryption.DecryptionException: Probable runtime exception on decryption:unknown parameter type. 
      at org.opensaml.xml.encryption.Decrypter.decryptKey(Decrypter.java:705) 
      at org.opensaml.xml.encryption.Decrypter.decryptKey(Decrypter.java:628) 
      at org.opensaml.xml.encryption.Decrypter.decryptUsingResolvedEncryptedKey(Decrypter.java:783) 
      at org.opensaml.xml.encryption.Decrypter.decryptDataToDOM(Decrypter.java:524) 
      at org.opensaml.xml.encryption.Decrypter.decryptDataToList(Decrypter.java:442) 
      at org.opensaml.xml.encryption.Decrypter.decryptData(Decrypter.java:403) 
      at org.opensaml.saml2.encryption.Decrypter.decryptData(Decrypter.java:141) 
      at org.opensaml.saml2.encryption.Decrypter.decrypt(Decrypter.java:69) 
      at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:199) 
      at org.springframework.security.saml.SAMLAuthenticationProvider.authenticate(SAMLAuthenticationProvider.java:82) 
      at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156) 
      at org.springframework.security.saml.SAMLProcessingFilter.attemptAuthentication(SAMLProcessingFilter.java:84) 
      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.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:166) 
      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.saml.metadata.MetadataGeneratorFilter.doFilter(MetadataGeneratorFilter.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:346) 
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) 
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503) 
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) 
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) 
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) 
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) 
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) 
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) 
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
      at java.lang.Thread.run(Thread.java:745) 
     Caused by: java.lang.IllegalArgumentException: unknown parameter type. 
      at org.bouncycastle.jce.provider.JCERSACipher.engineInit(Unknown Source) 
      at javax.crypto.Cipher.implInit(Cipher.java:791) 
      at javax.crypto.Cipher.chooseProvider(Cipher.java:849) 
      at javax.crypto.Cipher.init(Cipher.java:1348) 
      at javax.crypto.Cipher.init(Cipher.java:1282) 
      at org.apache.xml.security.encryption.XMLCipher.decryptKey(XMLCipher.java:1475) 
      at org.opensaml.xml.encryption.Decrypter.decryptKey(Decrypter.java:697) 
      ... 41 more 
     09:21:51,120 ERROR Decrypter:639 - Failed to decrypt EncryptedKey, valid decryption key could not be resolved 
     09:21:51,120 DEBUG Decrypter:787 - Attempt to decrypt EncryptedData using key extracted from EncryptedKey faile 

Trước đó tôi đã nhận được invalide lỗi kích thước quan trọng mà tôi cố định với sự giúp đỡ của Spring SAML ADFS: java.security.InvalidKeyException. Tuy nhiên tôi không chắc chắn liệu nó sẽ có bất kỳ tác động về pháp luật chính sách an ninh của Mỹ

. Nhưng ngoại lệ giải mã này là không nhận được giải quyết và không phù hợp của nó. Một thời gian nó bắt đầu làm việc sau khi khởi động máy chủ.

tôi đã cố gắng mỗi và tất cả mọi thứ trong 2-3 ngày qua. tôi nghĩ vấn đề xảy ra sau khi refresh siêu dữ liệu vì vậy tôi đã thử thêm thuộc tính bên dưới vào ResourceBacked Hạt MetadataProvider nhưng không may mắn.

<property name="parserPool" ref="parserPool"/> 
<property name="minRefreshDelay" value="120000"/> 
<property name="maxRefreshDelay" value="300000"/> 

Sau đó tôi gỡ lỗi WebSSOProfileConsumerImpl.java đang nghĩ này mught là vấn đề liên quan đến jira vì vậy tôi kiểm tra các mã mới nhất và tạo jar mới và bổ sung vào dự án của tôi nhưng không có may mắn.

Trả lời

2

Sau khi dành một tuần để gỡ lỗi và googling, tôi đã quyết định khắc phục sự cố này bằng một chút hack.

Tôi đã kiểm tra mã nguồn Spring-Saml từ nhánh Master của gitHub Repository và tạo jar và nhập nó vào dự án của tôi. Tôi nghĩ rằng vấn đề này SES-144 là tương tự như của tôi, vì vậy tôi đã thử với mã mới nhất nhưng không có may mắn.

Vì vậy, tôi quyết định gỡ lỗi mã xmlTooling.jar và tìm điểm chính xác của lỗi và ghi đè phương thức dưới đây decryptKey(EncryptedKey encryptedKey, String algorithm) trong XMLCipher.java bằng mã bên dưới.

Cipher c = constructCipher(encryptedKey.getEncryptionMethod() 
        .getAlgorithm(), encryptedKey.getEncryptionMethod() 
        .getDigestAlgorithm()); 

Instead of calling 
    c.init(4, key, oaepParameters); 
used below code and removed if/else block 
    c.init(4, key); 

Bạn có thể kiểm tra các lọ tùy chỉnh từ github

Bạn cần cập nhật phụ thuộc saml của bạn với dòng dưới đây trong tập tin pom.xml sử dụng jar tùy chỉnh này

<dependency> 
    <groupId>org.springframework.security.extensions</groupId> 
    <artifactId>spring-security-saml2-core</artifactId> 
    <version>1.0.1.RELEASE</version> 

    <exclusions> 
      <exclusion> 
        <artifactId>xmlsec</artifactId> 
        <groupId>org.apache.santuario</groupId> 
      </exclusion> 
    </exclusions> 
</dependency> 

<dependency> 
    <artifactId>xmlsec</artifactId> 
    <groupId>org.apache.santuario</groupId> 
    <version>1.5.6-custom</version> 
</dependency> 

Nếu bất cứ ai tìm thấy tốt hơn giải pháp xin vui lòng cho tôi biết.

Các vấn đề liên quan