mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Forgot to populate xml document. while I'm there use same code as signer to get signature
This commit is contained in:
parent
7c8f511eff
commit
ed14c2b1a1
@ -312,20 +312,22 @@ namespace Twiglet.CS2J.Translator
|
|||||||
if (Key == null)
|
if (Key == null)
|
||||||
throw new ArgumentException("Key");
|
throw new ArgumentException("Key");
|
||||||
|
|
||||||
// Create a new SignedXml object and pass it
|
// Add the namespace.
|
||||||
// the XML document class.
|
XmlNamespaceManager nsmgr = new XmlNamespaceManager(Doc.NameTable);
|
||||||
SignedXml signedXml = new SignedXml(Doc);
|
nsmgr.AddNamespace("ss", "http://www.w3.org/2000/09/xmldsig#");
|
||||||
|
|
||||||
// Find the "Signature" node and create a new
|
|
||||||
// XmlNodeList object.
|
|
||||||
XmlNodeList nodeList = Doc.GetElementsByTagName("Signature");
|
|
||||||
|
|
||||||
|
XmlNode root = Doc.DocumentElement;
|
||||||
|
XmlNodeList nodeList = root.SelectNodes("/*/ss:Signature", nsmgr);
|
||||||
// fail if no signature was found.
|
// fail if no signature was found.
|
||||||
if (nodeList.Count != 1)
|
if (nodeList.Count != 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a new SignedXml object and pass it
|
||||||
|
// the XML document class.
|
||||||
|
SignedXml signedXml = new SignedXml(Doc);
|
||||||
|
|
||||||
|
|
||||||
// Load the first <signature> node.
|
// Load the first <signature> node.
|
||||||
signedXml.LoadXml((XmlElement)nodeList[0]);
|
signedXml.LoadXml((XmlElement)nodeList[0]);
|
||||||
@ -346,7 +348,7 @@ namespace Twiglet.CS2J.Translator
|
|||||||
|
|
||||||
// Load an XML file into the XmlDocument object.
|
// Load an XML file into the XmlDocument object.
|
||||||
xmlDoc.PreserveWhitespace = true;
|
xmlDoc.PreserveWhitespace = true;
|
||||||
// xmlDoc.Load(txStream);
|
xmlDoc.Load(txStream);
|
||||||
|
|
||||||
// Verify the signature of the signed XML.
|
// Verify the signature of the signed XML.
|
||||||
if (!VerifyXml(xmlDoc, RsaKey))
|
if (!VerifyXml(xmlDoc, RsaKey))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user