Spring SAML示例:不支持SSOCircle SHA256

时间:2016-07-29 13:27:31

标签: java spring-security single-sign-on spring-saml

我正在尝试使用SSOCircle和默认密钥库的Spring SAML示例项目。 将SP元数据导入SSOCircle后,SSO正常工作。

现在,我想将加密算法从SHA-1更改为RSA SHA-256 。 所以我扩展了SAMLBootstrap类,如下所示:

public final class CustomSAMLBootstrap extends SAMLBootstrap {  

  @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        super.postProcessBeanFactory(beanFactory);
        BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
        config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
        config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
    }

此处还有扩展元数据配置

   <!-- Extended metadata properties -->
<bean id="extendedMetadataSP" class="org.springframework.security.saml.metadata.ExtendedMetadata">
    <property name="local" value="true"/>
    <property name="securityProfile" value="metaiop"/>
    <property name="sslSecurityProfile" value="pkix"/>
    <property name="signingKey" value="apollo"/>
    <property name="encryptionKey" value="apollo"/>
    <property name="signMetadata" value="true" />
    <property name="signingAlgorithm" value="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
    <property name="idpDiscoveryEnabled" value="true"/>
    <property name="idpDiscoveryURL" value="${entityBaseURL}/saml/discovery"/>
    <property name="idpDiscoveryResponseURL" value="${entityBaseURL}/saml/login?disco=true"/>

</bean>

所以我通过org.springframework.security.saml.metadata.MetadataGenerator bean重新生成了元数据,并尝试重新上传新生成的SP xml。虽然SSOCircle会因 007错误代码而失败。

enter image description here

此时我不确定是否为我在SSOCircle上使用sha256完成了附加步骤

有人可以帮忙吗?

修改

将元数据上传到SSOCircle时遇到的问题我认为它与EntityDescriptor部分有关,其中签名算法被指定为SHA256,如下所示:

 <?xml version="1.0"?>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
    <ds:Reference URI="#urn_com_apakgroup_bristol">
        <ds:Transforms>
            <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
        </ds:Transforms>
        <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
        <ds:DigestValue>mAT5iN6IWyTCQiPplFmOq4vu8SUzCBfpAC4XBOu2+eM=</ds:DigestValue>
    </ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>i6hH............bA==</ds:SignatureValue>
<ds:KeyInfo>
    <ds:X509Data>
        <ds:X509Certificate>MIIDZTCCA............eVdvh</ds:X509Certificate>
    </ds:X509Data>
</ds:KeyInfo>
</ds:Signature>

将signMetadata更改为false,遗憾的是它没有任何区别。

<property name="signMetadata" value="false" />

SAML回应:

2016-09-13 15:03:06,786 DEBUG org.opensaml.xml.security.SigningUtil:115 - Computing signature over input using private key of type RSA and JCA algorithm ID SHA256withRSA
2016-09-13 15:03:06,802 DEBUG org.opensaml.xml.security.SigningUtil:123 - Computed signature: 8b4...dfa9
2016-09-13 15:03:06,802 DEBUG opensaml.saml2.binding.encoding.HTTPRedirectDeflateEncoder:251 - Generated digital signature value (base64-encoded) i0...==
2016-09-13 15:03:06,803 DEBUG PROTOCOL_MESSAGE:74 - 
<?xml version="1.0" encoding="UTF-8"?><saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" AssertionConsumerServiceURL="http://localhost:8080/saml/SSO" Destination="https://idp.ssocircle.com:443/sso/SSORedirect/metaAlias/publicidp" ForceAuthn="false" ID="ac8eeg2j9d932hh4fe90fa71844e00" IsPassive="false" IssueInstant="2016-09-13T14:03:06.775Z" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Version="2.0">
   <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">...[my-sp]...</saml2:Issuer>
</saml2p:AuthnRequest>

2016-09-13 15:03:06,803 DEBUG opensaml.ws.message.encoder.BaseMessageEncoder:56 - Successfully encoded message.
2016-09-13 15:03:06,804 DEBUG springframework.security.saml.storage.HttpSessionStorage:93 - Storing message ac8eeg2j9d932hh4fe90fa71844e00 to session C17D8A94DED2F79BDD92CBF7A99462C6
2016-09-13 15:03:06,805  INFO springframework.security.saml.log.SAMLDefaultLogger:127 - AuthNRequest;SUCCESS;0:0:0:0:0:0:0:1;...[my-sp]...;https://idp.ssocircle.com;;;

1 个答案:

答案 0 :(得分:0)

error7的原因是无法验证元数据的签名。这在以下内容中进行了描述:how-to section&#34;签名的元数据可能会导致验证问题。我们建议删除签名作为最快的解决方法。&#34;

您启用了元数据签名:

<property name="signMetadata" value="true" /> 

将其转为&#34; false&#34;。