【发布时间】:2017-05-05 10:34:37
【问题描述】:
我按照spring saml tutorial 中的描述做了所有事情,除了我添加了
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
在 pom.xml 中克服 w3.dom 类未找到问题。当我运行示例项目时,我得到了
HTTP Status 401 - Authentication Failed: Error decoding incoming SAML message 在浏览器中,同时在控制台中 (CertPathPKIXTrustEvaluator.java:81) ERROR org.springframework.security.saml.trust.MetadataCredentialResolver - PKIX path construction failed for untrusted credential: [subjectName='CN=idp.ssocircle.com' |credential entityID='https://idp.ssocircle.com']: unable to find valid certification path to requested target。
第 2 天:
我运行keytool -importcert -alias identtrustca -file ca.cer -keystore samlKeystore.jks 并用新生成的替换security/samlKeystore.jks。 securityContext.xml:
<bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="classpath:security/samlKeystore.jks"/>
<constructor-arg type="java.lang.String" value="nalle123"/>
<constructor-arg>
<map>
<entry key="apollo" value="nalle123"/>
</map>
</constructor-arg>
<constructor-arg type="java.lang.String" value="apollo"/>
</bean>
那么我有:
Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
at java.security.KeyStore.load(Unknown Source)
at org.springframework.security.saml.key.JKSKeyManager.initialize(JKSKeyManager.java:117)
... 57 more
Caused by: java.security.UnrecoverableKeyException: Password verification failed
... 61 more
然后我把密码改成我使用keytool时输入的密码:
<bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="classpath:security/samlKeystore.jks"/>
<constructor-arg type="java.lang.String" value="123456"/>
<constructor-arg>
<map>
<entry key="apollo" value="123456"/>
</map>
</constructor-arg>
<constructor-arg type="java.lang.String" value="apollo"/>
</bean>
然后控制台说:
Servlet.service() for servlet [jsp] in context with path [/spring-security-saml2-sample] threw exception
java.lang.RuntimeException: Key for alias apollo not found
at org.springframework.security.saml.metadata.MetadataGenerator.getServerKeyInfo(MetadataGenerator.java:201)
所以我将apollo 更改为identtrustca:
<bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="classpath:security/samlKeystore.jks"/>
<constructor-arg type="java.lang.String" value="123456"/>
<constructor-arg>
<map>
<entry key="identtrustca" value="123456"/>
</map>
</constructor-arg>
<constructor-arg type="java.lang.String" value="identtrustca"/>
</bean>
控制台说:
Servlet.service() for servlet [jsp] in context with path [/spring-security-saml2-sample] threw exception
java.lang.UnsupportedOperationException: trusted certificate entries are not password-protected
然后我看了this和this,所以我删除了entry元素(我相信是私钥的东西),就变成了:
<bean id="keyManager" class="org.springframework.security.saml.key.JKSKeyManager">
<constructor-arg value="classpath:security/samlKeystore.jks"/>
<constructor-arg type="java.lang.String" value="123456"/>
<constructor-arg>
<map/>
</constructor-arg>
<constructor-arg type="java.lang.String" value="identtrustca"/>
</bean>
现在问题变成了:
Servlet.service() for servlet [jsp] in context with path [/spring-security-saml2-sample] threw exception
java.lang.RuntimeException: Key with alias identtrustca doesn't have a private key
第 2 天第 2 部分:
现在我明白了,我应该只使用旧的 samlKeystore.jks,而不是创建新的密钥库。如果使用keytool -list -V -keystore d:\temp\samlKeystore.jks 可以看到它包含 3 个项目(原来是 2 个)。
我不明白为什么 SP 从 IdP 元数据中获取公钥,但仍需要 IdP 的 ca.cer?我相信来自 auth 网站的 ca.cer 是 IdP 的证书,虽然它与我通过openssl s_client -connect idp.ssocircle.com:443 -showcerts 获得的证书不同
此外,现在我得到的是Error decoding incoming SAML message,而不是HTTP Status 401 - Authentication Failed: Response issue time is either too old or with date in the future
第 3 天 当我启动 SP,从 chrome 和 firefox 访问 http://localhost:8080/spring-security-saml2-sample/ 时,当我在一个资源管理器中按下全局注销并刷新另一个资源管理器时,它不会显示注销页面。我认为对于 SSO,来自同一个 SP 的全局注销应该忽略多会话,例如,一旦我在一个“登录”中全局注销,我应该在另一个“登录”中自动注销,我应该看到一个注销页面另一个资源管理器(如果我刷新)。实际上,对于多个SP,一个我注销一个,我应该能够看到我曾经登录的所有SP的注销。
第 n 天 通过更改 saml 项目 url,需要修改 idp.ssocircle.com 中的元数据(管理元数据)。否则,idp 网站会显示错误。这是写在 docs/reference/htmlsingle/index.html
【问题讨论】:
-
@VladimírSchäfer 嗨,我更新了问题,第 2 天部分。请看一下谢谢。
-
@VladimírSchäfer 请参阅第 2 天第 2 部分,第 2 天已清除。 :)
标签: spring-saml