【发布时间】:2017-05-14 15:06:50
【问题描述】:
我在某些项目中使用 opensaml 2.6.1 和 spring-security-saml2-core 1.0.1 来启用 SSO。 我正在使用自签名证书进行加密和签名。
当我的服务提供商收到 SAML 响应时,我收到以下错误:
DEBUG [org.opensaml.xml.signature.SignatureValidator] Creating XMLSignature object
DEBUG [org.opensaml.xml.signature.SignatureValidator] Validating signature with signature algorithm URI: http://www.w3.org/2001/04/xmldsig-more#rsa-sha512
DEBUG [org.opensaml.xml.signature.SignatureValidator] Validation credential key algorithm 'RSA', key instance class 'sun.security.rsa.RSAPublicKeyImpl'
DEBUG [org.opensaml.xml.signature.SignatureValidator] Signature validated with key from supplied credential
DEBUG [org.opensaml.xml.signature.impl.BaseSignatureTrustEngine] Signature validation using candidate credential was successful
DEBUG [org.opensaml.xml.signature.impl.BaseSignatureTrustEngine] Successfully verified signature using KeyInfo-derived credential
DEBUG [org.opensaml.xml.signature.impl.BaseSignatureTrustEngine] Attempting to establish trust of KeyInfo-derived credential
DEBUG [org.opensaml.xml.signature.impl.BaseSignatureTrustEngine] Failed to establish trust of KeyInfo-derived credential
DEBUG [org.opensaml.xml.signature.impl.BaseSignatureTrustEngine] Failed to verify signature and/or establish trust using any KeyInfo-derived credentials
DEBUG [org.opensaml.xml.signature.impl.ExplicitKeySignatureTrustEngine] Attempting to verify signature using trusted credentials
DEBUG [org.opensaml.xml.signature.impl.ExplicitKeySignatureTrustEngine] Failed to verify signature using either KeyInfo-derived or directly trusted credentials
DEBUG [org.springframework.security.saml.websso.WebSSOProfileConsumerImpl] Validation of authentication statement in assertion failed, skipping
org.opensaml.xml.validation.ValidationException: Signature is not trusted or invalid
at org.springframework.security.saml.websso.AbstractProfileBase.verifySignature(AbstractProfileBase.java:272)
at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.verifyAssertionSignature(WebSSOProfileConsumerImpl.java:419)
at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.verifyAssertion(WebSSOProfileConsumerImpl.java:292)
at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:214)
at org.springframework.security.saml.SAMLAuthenticationProvider.authenticate(SAMLAuthenticationProvider.java:82)
at
我从异常消息中了解到的内容是:
- 签名验证成功
- 信任我的证书时出现问题 我的假设是否正确?
我已使用以下命令将我的自签名证书导入我的密钥库(JVM 中的 cacerts 存储):
keytool -importcert -trustcacerts -file "myCcert.crt" -keystore "C:\Program Files\Java\jdk1.8.0_65\jre\lib\security\cacerts" -storepass changeit -alias test
此命令是否导入我的证书并将其标记为受 java 信任?
另一件事,java可以信任自签名签名还是我必须获得CA验证的证书才能通过验证?
【问题讨论】:
-
是的。 Java 可以信任自签名证书。
-
谢谢 anacron,那么这个异常的原因是什么?
-
如果您尝试实现 SSL,那么您将需要一个密钥库。
cacerts是信任库而不是密钥库。如果您想访问其他人的 SSL 站点,它可以正常工作。但是,如果您要在您的网站上设置 SSL,那么您将需要一个不同的密钥库。 -
我正在使用此认证进行签名/验证。我的认证已添加到 cacerts,为什么我仍然收到此异常?
标签: java keytool spring-saml opensaml java-security