A detached signature is neither the enveloped nor the enveloping one. The data can be in a sibling document in the XML tree or it can be stored in an external file or other resource. To create a detached signature, follow these steps:
' The following certificate will be used for signing
signingCert="CERT_FIND_SUBJECT_STR=CREA_TESTUSER_1"
' Load a sample xml from file
set doc=CreateObject("Msxml2.FreeThreadedDOMDocument.4.0")
doc.preserveWhiteSpace=true
doc.load "files\orders.xml"
' Create a template signature node
set template = CreateObject("CreaSignClientIE.XmlSignature")
' Add the template to the desired place in the source document
doc.documentElement.appendChild template.XmlNode
' Create the real signature object
' You must not use the template here because we have moved
' the underlying xml node by calling append child
set cs = CreateObject("CreaSignClientIE.XmlSignature")
set cs.XmlNode = template.XmlNode
' Now, append the reference which points only to the second order
set r = cs.AddReference("","#second","")
' Create a signature
cs.CreateSignature signingCert,0
' Save the result to a file
saveTo="files/signedDetached.xml"
if WScript.Arguments.Count>0 then saveTo=WScript.Arguments(0)
doc.save saveTo
WScript.Echo "Result saved to: " & saveTo(c) CREA 2002-2007 www.creasign.si