XML Digital Signature Error “The location of where to insert the Signature was not found.”

If your application fails to to sign XML and the XmlDSigGen.LastErrorText contains the error “The location of where to insert the Signature was not found.”, it means the location your application specified to put the Signature does not exist in the XML that is to be signed.

For example, if you wish to sign this XML:

<abc>
<xyz>test</xyz>
</abc>

and then you set gen.SigLocation = “abc|def”, then you’ll get the same error — because <abc><def> does not exist in the XML.

To further explain with a more real-world example.  Look at a sample of the signed XML you wish to produce such as the sample signed XML shown at

sdk.myinvois.hasil.gov.my/files/one-doc-signed.xml

Here is a snapshot of the 1st part of the signed XML:

Note where the “ds:Signature” is positioned.  The XML you are signing does not yet have the “ds:Signature” subtree added.  The “ds:Signature” subtree is what Chilkat is adding, and you need to tell Chilkat where to put that subtree in the XML you are signing. This is the purpose of the SigLocation property — to tell Chilkat the path in the XML where the “ds:Signature” should be inserted.

All we need to do is look at the above XML.  The path is easily seen to be:   “Invoice|ext:UBLExtensions|ext:UBLExtension|ext:ExtensionContent|sig:UBLDocumentSignatures|sac:SignatureInformation”

 

 

Tags :