0

SignedXmlDoc.CheckSignature always returning false in .NET 4.0 could you please help me on this on validation saml signature

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);
nagulu vemula
  • 119
  • 1
  • 10

1 Answers1

0

Have you seen this: SignedXml.CheckSignature fails in .NET 4 but it works in .NET 3.5, 3 or 2

Could be the same issue. Since don't see anything about cannonicalisation in your code.

Community
  • 1
  • 1
LeonG
  • 863
  • 4
  • 11