public bool VerifyXmlFile(XmlDocument xmlDocument) { if (xmlDocument == null) { throw new ArgumentException($"{nameof(xmlDocument)} cannot be null. Please supply a valid xml document"); } var signedXml = new CustomIdSignedXml(xmlDocument); var nodeList = xmlDocument.GetElementsByTagName(SignatureElementName, NS2); var xmlDigitalSignature = (XmlElement)nodeList[0]; if (xmlDigitalSignature == null) { return(true); } signedXml.LoadXml(xmlDigitalSignature); // Check the signature and return the result. return(signedXml.CheckSignature()); }
public void Hack() { XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; doc.Load(@"C:\TMP\cache.xml"); SignedXml sig = new CustomIdSignedXml(doc); XmlNodeList nodeList = doc.GetElementsByTagName("Signature", "http://www.w3.org/2000/09/xmldsig#"); foreach (XmlElement e in nodeList) { sig.LoadXml(e); Assert.IsTrue(sig.CheckSignature()); } }