SignedXml.CheckSignature fails in .NET 4 but it works in .NET 3.5, 3 or 2

前端 未结 8 1157
无人共我
无人共我 2020-12-07 00:14

I have a response from a 3-rd party web service. I load an XmlDocument with that response.

  string txt = readStream.ReadToEnd();
  response = new XmlDocumen         


        
8条回答
  •  情歌与酒
    2020-12-07 00:48

    public static Boolean VerifyDetachedSignature(string XmlSigFileName)
    {   
        // Create a new XML document.
        XmlDocument xmlDocument = new XmlDocument();
    
        // Load the passed XML file into the document.
        xmlDocument.Load(XmlSigFileName);
    
        // Find the "Signature" node and create a new XmlNodeList object.
        XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature");
    
        // Create a new SignedXMl object.
        SignedXml signedXml = new SignedXml();
    
        // Load the signature node.
        signedXml.LoadXml((XmlElement)nodeList[0]);
    
        // Check the signature and return the result. 
        return signedXml.CheckSignature();
    }
    

提交回复
热议问题