【问题标题】:SignedXmlDoc CheckSignature method returning falseSignedXmlDoc CheckSignature 方法返回 false
【发布时间】:2017-07-26 06:55:53
【问题描述】:

SignedXmlDoc.CheckSignature 在 .NET 4.0 中总是返回 false 能否请您在验证 saml 签名方面帮助我

CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
        X509Certificate2 cert = new X509Certificate2();
        string text = System.IO.File.ReadAllText(@"D:\TFS\KCWBB\Dev-2\Source\KC.WEM.ITGSMI.Web\File\sig.cert");
        cert.Import(Encoding.UTF8.GetBytes(text));
        XmlNodeList XMLSignatures = xnlDoc.GetElementsByTagName("Signature", "http://www.w3.org/2000/09/xmldsig#");



        KeyInfo key = new KeyInfo();
        KeyInfoX509Data data = new KeyInfoX509Data(cert);
        key.AddClause(data);

        // Checking If the Response or the Assertion has been signed once and only once.
        if (XMLSignatures.Count == 0) return false;

        var signedXmlDoc = new SignedXml(xnlDoc);
        signedXmlDoc.LoadXml((XmlElement)XMLSignatures[0]);
        if (cert == null)
        {
            return false;
        }


        return signedXmlDoc.CheckSignature(cert,true);

【问题讨论】:

    标签: .net saml


    【解决方案1】:

    你见过这样的: SignedXml.CheckSignature fails in .NET 4 but it works in .NET 3.5, 3 or 2

    可能是同一个问题。因为在您的代码中看不到任何关于规范化的内容。

    【讨论】:

      猜你喜欢
      • 2022-12-14
      • 2012-02-11
      • 2011-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-22
      • 2016-04-06
      • 2021-12-20
      相关资源
      最近更新 更多