预期的签名算法不匹配

时间:2016-01-20 06:02:35

标签: single-sign-on opensaml

我正在尝试实施SSO。在我的SP元数据中,我已将签名和加密算法设置为sha256

    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="" />
            <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
            <ds:Reference URI="">
                <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 />
            </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue />
    </ds:Signature>

在我的身份验证请求中,我也发送请求为:

 Signature signature = (Signature) Configuration.getBuilderFactory()
        .getBuilder(Signature.DEFAULT_ELEMENT_NAME)
        .buildObject(Signature.DEFAULT_ELEMENT_NAME);
    signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
    authnRequest.setSignature(signature);
    ((SAMLObjectContentReference)signature.getContentReferences().get(0)).setDigestAlgorithm(EncryptionConstants.ALGO_ID_DIGEST_SHA256);  

在依赖方高级选项卡下的IDP端,我交叉检查SHA-256被设置为哈希算法,但现在当我发送身份验证请求时,我得到错误:

  `SAML request is not signed with expected signature algorithm. SAML request is signed with signature algorithm` http://www.w3.org/2001/04/xmldsig-more#rsa-sha256 . Expected signature algorithm is http://www.w3.org/2000/09/xmldsig#rsa-sha1 

如果我错过了某个地方的某些内容,请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

这对我有用!

在向IDP发送身份验证请求时,我必须设置这两行。

BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);

这会全局设置算法,如果您有多个具有不同签名算法的客户端

,则无效