Spring security Spring Security SAML-验证签名失败
我在Tomcat7上使用SpringSecuritySAML2.0示例webapp,并对其进行了修改,以使其能够针对Ping身份服务进行身份验证。webapp正在与服务对话,并且正在发回一个断言,但在尝试验证签名时失败,如下调试输出所示:Spring security Spring Security SAML-验证签名失败,spring-security,digital-signature,x509,saml-2.0,spring-saml,Spring Security,Digital Signature,X509,Saml 2.0,Spring Saml,我在Tomcat7上使用SpringSecuritySAML2.0示例webapp,并对其进行了修改,以使其能够针对Ping身份服务进行身份验证。webapp正在与服务对话,并且正在发回一个断言,但在尝试验证签名时失败,如下调试输出所示: - Attempting to verify signature and establish trust using KeyInfo-derived credentials - Signature contained no KeyInfo element, c
- Attempting to verify signature and establish trust using KeyInfo-derived credentials
- Signature contained no KeyInfo element, could not resolve verification credentials
- Failed to verify signature and/or establish trust using any KeyInfo-derived credentials
- Attempting to verify signature using trusted credentials
- Failed to verify signature using either KeyInfo-derived or directly trusted credentials
- Validation of received assertion failed, assertion will be skipped
org.opensaml.xml.validation.ValidationException: Signature is not trusted or invalid
我知道它无法验证签名,Ping身份管理员已经给了我一个证书供我使用,但我不确定如何将其包含在应用程序中。我尝试使用JDK的keytool程序将其添加到示例应用程序附带的JKS(密钥库)中,但它似乎在其中找不到。我还尝试将其添加到服务提供商的元数据xml文件中,如下所示:
<md:KeyDescriptor use="signing">
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Data>
<ds:X509Certificate>
[Certificate is here...]
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</md:KeyDescriptor>
<bean class="org.springframework.security.saml.metadata.ExtendedMetadataDelegate">
<constructor-arg>
<bean class="org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider">
<constructor-arg>
<value type="java.io.File">classpath:security/[Path to SP metadata xml file].xml</value>
</constructor-arg>
<property name="parserPool" ref="parserPool" />
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.security.saml.metadata.ExtendedMetadata">
<property name="alias" value="[SP alias goes here]" />
<property name="signingKey" value="[alias of the provided key in the JKS goes here]"/>
</bean>
</constructor-arg>
</bean>
[证书在这里…]
但是,它仍然返回相同的错误
为了验证签名,我是否应该将证书放在特定的位置?一般来说,我对SAML和应用程序安全性还比较陌生,所以如果我使用了错误的术语,我很抱歉。终于做到了这一点。事实证明,我遗漏了安全上下文文件中的一行配置,并且(看起来似乎)服务提供商的元数据XML文件中不需要X509证书定义 基本上,我已经将提供给我的公钥导入到现有的JKS中(使用
keytool
),但我没有告诉应用程序具体使用它。为此,我必须进入安全上下文文件(在我的例子中是“securityContext.xml”),并为SP的元数据xml文件的extendedmatadata
bean定义添加以下行:
<property name="signingKey" value="[alias of the provided key in the JKS goes here]"/>
希望这能帮助任何处于类似情况的人。感谢您的洞察力。我正在尝试同样的事情,但不断地出错。我想知道你是如何处理keyManager bean的?我认为这个bean是必要的,它坚持提供私钥。这样做时,将在ADFS中导入的结果元数据中缺少公钥