Sign an XML file
Namespace: FirmaSATAssembly: diFirmaSatNet (in diFirmaSatNet.dll) Version: 10.70.0.38178 (10.70.0.0)
Syntaxpublic static int SignXml(
string newFile,
string baseFile,
string keyFile,
string password = "",
string certFile = "",
SignOptions signOpts = SignOptions.Default
)
Public Shared Function SignXml (
newFile As String,
baseFile As String,
keyFile As String,
Optional password As String = "",
Optional certFile As String = "",
Optional signOpts As SignOptions = SignOptions.Default
) As Integer
Parameters
- newFile String
- Name of new file to be created
- baseFile String
- Name of base XML file to be signed (or a string containing XML data)
- keyFile String
- Name of private key file
- password String (Optional)
- Password
- certFile String (Optional)
- Name of X.509 certificate file to be included in output XML (optional)
- signOpts SignOptions (Optional)
- Options for output format (optional)
Return Value
Int320 if successful or non-zero
error code if failed
Remarks This will create an output XML document copied from the input with the
Sello node overwritten by a new signature value.
Any existing file called
newFile will be overwritten without warning; however, the input and output files can be the same.
If a certificate file szCertFile is specified then the Certificado and NoCertificado nodes will be overwritten
in the output file with the values in the certificate file.
If a certificate file is not specified then the Certificado value in the XML will be used.
A version 4 CFDi document to be signed
must use the "cfdi:" namespace prefix.
For CFD v4 the
NoCertificado attribute in the input must be set to the correct certificate serial number before signing.
In a Retenciones document you must set the
CertNum attribute before signing.
In a ControlesVolumetricos document you must set both the
noCertificado and
certificado attributes before signing.
Exampleint n = Sat.SignXml("cfdv40-signed_new.xml", "cfdv40-ejemplo.xml", "emisor.key", "12345678a", "emisor.cer");
See Also