C# why XmlDsigC14NTransform remove all whitespaces from xml -


i have problem xmldsigc14ntransform. trying repeat example http://www.di-mgt.com.au/xmldsig2.html (part compose canonicalized signedinfo element , compute signaturevalue) code loses whitespaces xml , cant correct hexdump.

my c# code:

 xmldocument signedinfoxml = new xmldocument();  signedinfoxml.load(@"c:\temp\new_sign.txt");   xmldsigc14ntransform xmltransform = new xmldsigc14ntransform();  xmltransform.loadinput(signedinfoxml);  memorystream memorystream = (memorystream)xmltransform.getoutput();  return  bitconverter.tostring(memorystream.toarray()).replace("-"," "); 

source xml(from file c:\temp\new_sign.txt):

<signedinfo  xmlns="http://www.w3.org/2000/09/xmldsig#">       <canonicalizationmethod algorithm="http://www.w3.org/tr/2001/rec-xml-c14n-20010315" />       <signaturemethod algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />       <reference uri="">         <transforms>           <transform algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />         </transforms>         <digestmethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />         <digestvalue>uwuytyug10j1k5hkfonxthgrar8=</digestvalue>       </reference>     </signedinfo> 

how can save whitespaces xml , canonicalized xml in sample (http://www.di-mgt.com.au/xmldsig2.html)?

you can set flag on xmldocument:

    // create new xml document.     xmldocument xmldocument = new xmldocument();      // format using white spaces.     xmldocument.preservewhitespace = true;      // load xml file document.      xmldocument.load("file.xml"); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -