c# - How Do I Import A Xades Signed Xml Document Into Another Xml Document? -


i trying import signed xml document xml document. when import document, , export no change, can no longer validate it.

even code below breaks validation.

openfiledialog ofd = new openfiledialog(); ofd.showdialog();  if (ofd.filename != "") {    xmldocument xmldocument = new xmldocument();    xmldocument.load(ofd.filename);     folderbrowserdialog fbd = new folderbrowserdialog();    fbd.showdialog();     if (fbd.selectedpath != "")    {       xmldocument.save(fbd.selectedpath + @"\doc.xml");    } } 

how can import/export xml document without breaking signature validation?

my xml files are:

invoice.xml document signed. want import invoice.xml envelope.xml. element of envelope.xml, invoice.xml going imported, shown.

given following signed xml:

<?xml version="1.0"?> <mysignedxmlroot xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">   <mysignedxmlnode>texttobesigned</mysignedxmlnode>   <signature xmlns="http://www.w3.org/2000/09/xmldsig#">     <signedinfo>       <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>3tajl2x1semhxq1hp9x4hbutsgq=</digestvalue>       </reference>     </signedinfo>     <signaturevalue>uyyeldlqq1inzswskozhiuatu52gdvfw0aqnzxob0xqr6cs2hbw5tzixc6fmpsystyfmvulo1ziorkhvyiy7lqer/i4cyzva1vpztnx+0gzecpfeumorngj0v/w7nhi5xjb6uxkdzbcsmlefwittho+tph8tha0cndp4xo8xx4y=</signaturevalue>   </signature> </mysignedxmlroot> 

if want include in following xml document:

<myxml>     <somedata>random data</somedata>     <container/> </myxml> 

you have correctly set reference attribute of signature:

<myxml>     <somedata>random data</somedata>     <container>         <mysignedxmlroot id="elementtosign" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance">             <mysignedxmlnode>texttobesigned</mysignedxmlnode>             <signature xmlns="http://www.w3.org/2000/09/xmldsig#">                 <signedinfo>                     <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="#elementtosign">                         <transforms>                             <transform algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />                         </transforms>                         <digestmethod algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />                         <digestvalue>3tajl2x1semhxq1hp9x4hbutsgq=</digestvalue>                     </reference>                 </signedinfo>                 <signaturevalue>uyyeldlqq1inzswskozhiuatu52gdvfw0aqnzxob0xqr6cs2hbw5tzixc6fmpsystyfmvulo1ziorkhvyiy7lqer/i4cyzva1vpztnx+0gzecpfeumorngj0v/w7nhi5xjb6uxkdzbcsmlefwittho+tph8tha0cndp4xo8xx4y=</signaturevalue>             </signature>         </mysignedxmlroot>     </container> </myxml> 

you can set reference.uri


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -