【问题标题】:Expected Signature Algorithm does not match预期的签名算法不匹配
【发布时间】:2016-01-21 13:59:21
【问题描述】:

我正在尝试实施 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 

如果我在某处遗漏了什么,请帮我解决这个问题。

【问题讨论】:

    标签: single-sign-on opensaml


    【解决方案1】:

    这对我有用!

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

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

    这会全局设置算法,当您有多个具有不同签名算法的客户端时不起作用

    【讨论】:

      猜你喜欢
      • 2019-11-07
      • 2014-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-24
      • 2019-09-04
      • 1970-01-01
      • 2021-03-26
      相关资源
      最近更新 更多