Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

SQL Server Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(SQL Server) Create XAdES-EPES Factura Electrónica Signature

Demonstrates how to create an XAdES-EPES signature. The sample data is for the Costa Rica Factura Electrónica (http://www.hacienda.go.cr/contenido/14350-factura-electronica)

Note: This example requires Chilkat v9.5.0.75 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example requires the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    -- This example will add an XAdES-EPES signature to the file
    -- at FacturaElectronica_cr.xml
    -- 
    -- The XML to be signed looks like this:

    -- 	<?xml version="1.0" encoding="UTF-8"?>
    -- 	<FacturaElectronica xmlns="https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica" 
    --                xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    -- 	   <Clave>70609022800030259092400100001010000000005100001701</Clave>
    -- 	   <NumeroConsecutivo>00100001010000000007</NumeroConsecutivo>
    -- 	   <FechaEmision>2018-02-08T22:05:20.3925782-06:00</FechaEmision>
    -- 	   <Emisor>
    -- 	   ...
    -- 	   </Emisor>
    -- 	   ...
    -- 	   <Normativa>
    -- 	      <NumeroResolucion>DGT-R-48-2016</NumeroResolucion>
    -- 	      <FechaResolucion>20-02-2017 13:22:22</FechaResolucion>
    -- 	   </Normativa>
    -- 	</FacturaElectronica>

    -- First load a certificate w/ private key from a .pfx.
    -- (There are many different ways to provide the certificate + private key for signing.
    -- loading a .pfx is just one particular way of doing it..)

    DECLARE @cert int
    -- Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Cert', @cert OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int
    EXEC sp_OAMethod @cert, 'LoadPfxFile', @success OUT, 'qa_data/pfx/cert_test123.pfx', 'test123'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @cert
        RETURN
      END

    -- Load XML to be signed.
    DECLARE @sbXml int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbXml OUT

    EXEC sp_OAMethod @sbXml, 'LoadFile', @success OUT, 'qa_data/xades/factura_cr/FacturaElectronica.xml', 'utf-8'
    IF @success <> 1
      BEGIN

        PRINT 'Failed to load file.'
        EXEC @hr = sp_OADestroy @cert
        EXEC @hr = sp_OADestroy @sbXml
        RETURN
      END

    DECLARE @gen int
    -- Use "Chilkat_9_5_0.XmlDSigGen" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.XmlDSigGen', @gen OUT

    -- Indicate where the signature is to be placed.
    EXEC sp_OASetProperty @gen, 'SigLocation', 'FacturaElectronica'
    -- The SigId can be any random unique string in any format (in other words, there is no expected format).  
    -- For example, "Hello_23946359203502" or "A3982BF7130C".  It is arbitrary.
    -- However, other parts of the XML will reference the ID you use here.  (Search for the same string below and you'll see...)
    EXEC sp_OASetProperty @gen, 'SigId', 'Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0'
    EXEC sp_OASetProperty @gen, 'SigNamespacePrefix', 'ds'
    EXEC sp_OASetProperty @gen, 'SignedInfoCanonAlg', 'C14N'
    EXEC sp_OASetProperty @gen, 'SignedInfoDigestMethod', 'sha256'

    -- --------------------------------------------------------------------
    -- We want to build the QualifyingProperties XML, as shown below:
    -- You can generate the code that creates this XML using the online tool 
    -- at XML Code Generator

    -- I've place a copy of the QualifyingProperties XML at
    -- QualifyingProperties_cr.xml

    --          <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Id="QualifyingProperties-aa262416-8607-4f02-8897-0a6440a1ae03" Target="#Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --             <xades:SignedProperties Id="SignedProperties-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --                <xades:SignedSignatureProperties>
    --                   <xades:SigningTime>TO BE GENERATED BY CHILKAT</xades:SigningTime>
    --                   <xades:SigningCertificate>
    --                      <xades:Cert>
    --                         <xades:CertDigest>
    --                            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
    --                            <ds:DigestValue>TO BE GENERATED BY CHILKAT</ds:DigestValue>
    --                         </xades:CertDigest>
    --                         <xades:IssuerSerial>
    --                            <ds:X509IssuerName>TO BE GENERATED BY CHILKAT</ds:X509IssuerName>
    --                            <ds:X509SerialNumber>TO BE GENERATED BY CHILKAT</ds:X509SerialNumber>
    --                         </xades:IssuerSerial>
    --                      </xades:Cert>
    --                   </xades:SigningCertificate>
    --                   <xades:SignaturePolicyIdentifier>
    --                      <xades:SignaturePolicyId>
    --                         <xades:SigPolicyId>
    --                            <xades:Identifier>https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/Resolucion%20Comprobantes%20Electronicos%20%20DGT-R-48-2016.pdf</xades:Identifier>
    --                            <xades:Description />
    --                         </xades:SigPolicyId>
    --                         <xades:SigPolicyHash>
    --                            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
    --                            <ds:DigestValue>NmI5Njk1ZThkNzI0MmIzMGJmZDAyNDc4YjUwNzkzODM2NTBiOWUxNTBkMmI2YjgzYzZjM2I5NTZlNDQ4OWQzMQ==</ds:DigestValue>
    --                         </xades:SigPolicyHash>
    --                      </xades:SignaturePolicyId>
    --                   </xades:SignaturePolicyIdentifier>
    --                </xades:SignedSignatureProperties>
    --                <xades:SignedDataObjectProperties>
    --                   <xades:DataObjectFormat ObjectReference="#Reference-ab26afbd-e2dc-4cb0-886a-ce2a4a118c7f">
    --                      <xades:MimeType>text/xml</xades:MimeType>
    --                      <xades:Encoding>UTF-8</xades:Encoding>
    --                   </xades:DataObjectFormat>
    --                </xades:SignedDataObjectProperties>
    --             </xades:SignedProperties>
    --          </xades:QualifyingProperties>
    -- 

    -- This is the code generated by the online tool to create the above XML.
    -- Note: Chilkat will automatically populate the strings indicated by "TO BE GENERATED BY CHILKAT" with actual/correct values
    -- when the XML is signed.
    DECLARE @xml int
    -- Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT

    EXEC sp_OASetProperty @xml, 'Tag', 'xades:QualifyingProperties'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'xmlns:xades', 'http://uri.etsi.org/01903/v1.3.2#'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'Id', 'QualifyingProperties-aa262416-8607-4f02-8897-0a6440a1ae03'
    EXEC sp_OAMethod @xml, 'AddAttribute', @success OUT, 'Target', '#Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'xades:SignedProperties', 1, 'Id', 'SignedProperties-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningTime', 'TO BE GENERATED BY CHILKAT'
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestMethod', 1, 'Algorithm', 'http://www.w3.org/2001/04/xmlenc#sha256'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestValue', 'TO BE GENERATED BY CHILKAT'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509IssuerName', 'TO BE GENERATED BY CHILKAT'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509SerialNumber', 'TO BE GENERATED BY CHILKAT'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier', 'https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/Resolucion%20Comprobantes%20Electronicos%20%20DGT-R-48-2016.pdf'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Description', ''
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestMethod', 1, 'Algorithm', 'http://www.w3.org/2001/04/xmlenc#sha256'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue', 'NmI5Njk1ZThkNzI0MmIzMGJmZDAyNDc4YjUwNzkzODM2NTBiOWUxNTBkMmI2YjgzYzZjM2I5NTZlNDQ4OWQzMQ=='
    EXEC sp_OAMethod @xml, 'UpdateAttrAt', @success OUT, 'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat', 1, 'ObjectReference', '#Reference-ab26afbd-e2dc-4cb0-886a-ce2a4a118c7f'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:MimeType', 'text/xml'
    EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Encoding', 'UTF-8'

    -- --------------------------------------------------------------------
    -- Add the QualifyingProperties as an Object in the Signature that is to be produced.

    EXEC sp_OAMethod @xml, 'GetXml', @sTmp0 OUT
    EXEC sp_OAMethod @gen, 'AddObject', @success OUT, 'XadesObjectId-674a431e-692c-4e0a-9d82-6275c85c5876', @sTmp0, '', ''

    -- Add a Reference to the SignedProperties.
    DECLARE @signedPropsId nvarchar(4000)
    SELECT @signedPropsId = 'SignedProperties-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0'
    EXEC sp_OAMethod @gen, 'AddObjectRef', @success OUT, @signedPropsId, 'sha256', 'EXCL_C14N', '', 'http://uri.etsi.org/01903#SignedProperties'

    -- When the Signature is generated, the Reference to the SignedProperties will look like this:

    --          <ds:Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#SignedProperties-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --             <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
    --             <ds:DigestValue>GLOA1AWNZhJM9NlK515TJmCE+/EKHlrIQJkkyTPPL4E=</ds:DigestValue>
    --          </ds:Reference>

    -- --------------------------------------------------------------------
    -- Add a reference to the KeyInfo, which does not yet exist because it will be
    -- generated as part of the Signature.  However, we can specify the KeyInfo Id,
    -- and then specify that during signature generation, a reference to the KeyInfo (using the Id)
    -- should be added.

    -- We'll want a KeyInfo that will look like this:

    --          <ds:Reference Id="ReferenceKeyInfo" URI="#KeyInfoId-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --             <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
    --             <ds:DigestValue>hbYK/DyNGpK4HtUQV8xsljxbrTJY4AS0SYOa1oW/FQw=</ds:DigestValue>
    --          </ds:Reference>

    DECLARE @keyInfoId nvarchar(4000)
    SELECT @keyInfoId = 'KeyInfoId-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0'
    EXEC sp_OASetProperty @gen, 'KeyInfoId', @keyInfoId
    EXEC sp_OAMethod @gen, 'AddSameDocRef', @success OUT, @keyInfoId, 'sha256', 'EXCL_C14N', '', ''
    EXEC sp_OAMethod @gen, 'SetRefIdAttr', @success OUT, @keyInfoId, 'ReferenceKeyInfo'

    -- --------------------------------------------------------------------
    -- Add our 3rd and final Reference, which is to the root element of the XML document being signed.

    EXEC sp_OAMethod @gen, 'AddSameDocRef', @success OUT, '', 'sha256', 'EXCL_C14N', '', ''
    EXEC sp_OAMethod @gen, 'SetRefIdAttr', @success OUT, '', 'Reference-ab26afbd-e2dc-4cb0-886a-ce2a4a118c7f'

    -- The 3rd Reference will look like this:

    --          <ds:Reference Id="Reference-ab26afbd-e2dc-4cb0-886a-ce2a4a118c7f" URI="">
    --             <ds:Transforms>
    --                <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
    --             </ds:Transforms>
    --             <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
    --             <ds:DigestValue>BvbWtgU5sBzQpS4xHOocHHmj97o/M895BsYb0ce+3LA=</ds:DigestValue>
    --          </ds:Reference>

    -- ----------------------------------------------------------------
    -- Provide the KeyInfo information.
    EXEC sp_OASetProperty @gen, 'KeyInfoType', 'X509Data'
    EXEC sp_OASetProperty @gen, 'X509Type', 'Certificate'
    EXEC sp_OAMethod @gen, 'SetX509Cert', @success OUT, @cert, 1
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @gen, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @cert
        EXEC @hr = sp_OADestroy @sbXml
        EXEC @hr = sp_OADestroy @gen
        EXEC @hr = sp_OADestroy @xml
        RETURN
      END

    -- --------------------------------------------------------------------
    -- Create the XAdES-EPES signed XML.
    EXEC sp_OASetProperty @gen, 'Behaviors', 'IndentedSignature'

    EXEC sp_OAMethod @gen, 'CreateXmlDSigSb', @success OUT, @sbXml
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @gen, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @cert
        EXEC @hr = sp_OADestroy @sbXml
        EXEC @hr = sp_OADestroy @gen
        EXEC @hr = sp_OADestroy @xml
        RETURN
      END

    -- Examine the signed XML
    EXEC sp_OAMethod @sbXml, 'GetAsString', @sTmp0 OUT
    PRINT @sTmp0

    -- The following XAdES-EPES signed XML is produced:

    -- <?xml version="1.0" encoding="UTF-8"?>
    -- <FacturaElectronica xmlns="https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/facturaElectronica" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    --    <Clave>70609022800030259092400100001010000000005100001701</Clave>
    --    <NumeroConsecutivo>00100001010000000007</NumeroConsecutivo>
    --    <FechaEmision>2018-02-08T22:05:20.3925782-06:00</FechaEmision>
    --    <Emisor>
    --       <Nombre>Xavier Zarpio Yonge</Nombre>
    --       <Identificacion>
    --          <Tipo>01</Tipo>
    --          <Numero>302590926</Numero>
    --       </Identificacion>
    --       <NombreComercial />
    --       <Ubicacion>
    --          <Provincia>3</Provincia>
    --          <Canton>01</Canton>
    --          <Distrito>01</Distrito>
    --          <Barrio>01</Barrio>
    --          <OtrasSenas>555 al sur de la plaza los Angeles.</OtrasSenas>
    --       </Ubicacion>
    --       <Telefono>
    --          <CodigoPais>506</CodigoPais>
    --          <NumTelefono>99929567</NumTelefono>
    --       </Telefono>
    --       <Fax>
    --          <CodigoPais>506</CodigoPais>
    --          <NumTelefono>99929567</NumTelefono>
    --       </Fax>
    --       <CorreoElectronico>xavieryarpio@gmail.com</CorreoElectronico>
    --    </Emisor>
    --    <Receptor>
    --       <Nombre>Andy Malamar Catal�n</Nombre>
    --       <Identificacion>
    --          <Tipo>01</Tipo>
    --          <Numero>305580724</Numero>
    --       </Identificacion>
    --       <NombreComercial />
    --       <Ubicacion>
    --          <Provincia>3</Provincia>
    --          <Canton>01</Canton>
    --          <Distrito>01</Distrito>
    --          <Barrio>01</Barrio>
    --          <OtrasSenas>Cartago, los �ngeles</OtrasSenas>
    --       </Ubicacion>
    --       <Telefono>
    --          <CodigoPais>506</CodigoPais>
    --          <NumTelefono>84431131</NumTelefono>
    --       </Telefono>
    --       <Fax>
    --          <CodigoPais>506</CodigoPais>
    --          <NumTelefono>00000000</NumTelefono>
    --       </Fax>
    --       <CorreoElectronico>andycatalan12@hotmail.es</CorreoElectronico>
    --    </Receptor>
    --    <CondicionVenta>01</CondicionVenta>
    --    <PlazoCredito>0</PlazoCredito>
    --    <MedioPago>01</MedioPago>
    --    <DetalleServicio>
    --       <LineaDetalle>
    --          <NumeroLinea>1</NumeroLinea>
    --          <Codigo>
    --             <Tipo>01</Tipo>
    --             <Codigo>11</Codigo>
    --          </Codigo>
    --          <Cantidad>1.000</Cantidad>
    --          <UnidadMedida>Unid</UnidadMedida>
    --          <UnidadMedidaComercial />
    --          <Detalle>servicios profesionales</Detalle>
    --          <PrecioUnitario>30000.00000</PrecioUnitario>
    --          <MontoTotal>30000.00000</MontoTotal>
    --          <NaturalezaDescuento />
    --          <SubTotal>30000.00000</SubTotal>
    --          <MontoTotalLinea>30000.00000</MontoTotalLinea>
    --       </LineaDetalle>
    --    </DetalleServicio>
    --    <ResumenFactura>
    --       <CodigoMoneda>CRC</CodigoMoneda>
    --       <TipoCambio>1.00000</TipoCambio>
    --       <TotalServGravados>0.00000</TotalServGravados>
    --       <TotalServExentos>30000.00000</TotalServExentos>
    --       <TotalMercanciasGravadas>0.00000</TotalMercanciasGravadas>
    --       <TotalMercanciasExentas>0.00000</TotalMercanciasExentas>
    --       <TotalGravado>0.00000</TotalGravado>
    --       <TotalExento>30000.00000</TotalExento>
    --       <TotalVenta>30000.00000</TotalVenta>
    --       <TotalDescuentos>0.00000</TotalDescuentos>
    --       <TotalVentaNeta>30000.00000</TotalVentaNeta>
    --       <TotalImpuesto>0.00000</TotalImpuesto>
    --       <TotalComprobante>30000.00000</TotalComprobante>
    --    </ResumenFactura>
    --    <Normativa>
    --       <NumeroResolucion>DGT-R-48-2016</NumeroResolucion>
    --       <FechaResolucion>20-02-2017 13:22:22</FechaResolucion>
    --    </Normativa>
    -- <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --   <ds:SignedInfo>
    --     <ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
    --     <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
    --     <ds:Reference URI="#SignedProperties-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0" Type="http://uri.etsi.org/01903#SignedProperties">
    --       <ds:Transforms>
    --         <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    --       </ds:Transforms>
    --       <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
    --       <ds:DigestValue>rk9bKozGf7gos5+gk77yd+6Or71uMtLKanLlJQ1CCJ4=</ds:DigestValue>
    --     </ds:Reference>
    --     <ds:Reference Id="Reference-ab26afbd-e2dc-4cb0-886a-ce2a4a118c7f" URI="#KeyInfoId-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --       <ds:Transforms>
    --         <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    --       </ds:Transforms>
    --       <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
    --       <ds:DigestValue>AHAsUXqwwBjpkiSelrzz7TJ7WjbM3IWOOF210YuYSEU=</ds:DigestValue>
    --     </ds:Reference>
    --     <ds:Reference Id="Reference-ab26afbd-e2dc-4cb0-886a-ce2a4a118c7f" URI="">
    --       <ds:Transforms>
    --         <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
    --         <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    --       </ds:Transforms>
    --       <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
    --       <ds:DigestValue>sU/yIR2Wh8xEaMQswFjQv65VCCm/1m/0Q+WZoORItw8=</ds:DigestValue>
    --     </ds:Reference>
    --   </ds:SignedInfo>
    --   <ds:SignatureValue>XL2OfTTE8mOwfF3jzZ9A+21xKImA6ClpahXwA7twJ4O6Zw4zLd9M4WIFOEd288Uch+Uvd3ixz+zn+F5ubkQS276DQ9WRIPwqaBapf3LqOjs3TcWq39UJbyq7Cnwd14HA5kefKZSzBLS8icoNpMm8/0vVJ7IyO9r10cxNZ5FMY8IAMRuQXRGNLvwRL+NVN4ZrH0ga6lkUciTfUi4ESJQBoRXyF6yLFbZry45ozXlrNFlrNIAwZf30L1+0MZKCp8MAlU8Sf+PfDWkMJ6ii1iaQkFFR6D4nrTi+9ZjDzNIwkfBvuAmouwEndhvcplBfHaiQFlbQmxqkQ9sjYeUH3X+ceg==</ds:SignatureValue>
    --   <ds:KeyInfo Id="KeyInfoId-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --     <ds:X509Data>
    --       <ds:X509Certificate>MIIFNTCCBB2gAwIBAgIQHozVnBl1lTsusAh26u6WZTANBgkqhkiG9w0BAQsFADCBlzELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxPTA7BgNVBAMTNENPTU9ETyBSU0EgQ2xpZW50IEF1dGhlbnRpY2F0aW9uIGFuZCBTZWN1cmUgRW1haWwgQ0EwHhcNMTcxMjE0MDAwMDAwWhcNMTgxMjE0MjM1OTU5WjAmMSQwIgYJKoZIhvcNAQkBFhVhc2Rhc2Rhc2Rhc2RkQGJ5b20uZGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC96oQe50EDoiuJVITeKJzy6GzVq74cEa14eFypjMNbYVyedfCI6cn9pVClLqL7dlwxFGCRA62bbNE9woKLBT3SO1IvgoFDVIrbJm+84GEoqQReZe8HpZnF06d3DWwhUjjcuO1z2yliGdSymSee8/1OaztxEAEOWaZR+4MkfSNcAzzjGtKcKjVMSdiiO0JGAG/IXEwzlulfkF8zVdqDGkQTQesvT4WBys4BYwTDI64dsM7rcC9vwuK6gvpkUi9i1Wzu0W4v9T3iHAbl3rLihPcjQ95c4q7+NjwpRqQW1VXRenR/0iyLEFOek0D4JvOoscUwJ0LYd8f9SxFEWIzc4iAfAgMBAAGjggHrMIIB5zAfBgNVHSMEGDAWgBSCr2yM+MX+lmF86B89K3FIXsSLwDAdBgNVHQ4EFgQUrC0DOyBBAgOWgo2EfVZbppe3xfEwDgYDVR0PAQH/BAQDAgWgMAwGA1UdEwEB/wQCMAAwIAYDVR0lBBkwFwYIKwYBBQUHAwQGCysGAQQBsjEBAwUCMBEGCWCGSAGG+EIBAQQEAwIFIDBGBgNVHSAEPzA9MDsGDCsGAQQBsjEBAgEBATArMCkGCCsGAQUFBwIBFh1odHRwczovL3NlY3VyZS5jb21vZG8ubmV0L0NQUzBaBgNVHR8EUzBRME+gTaBLhklodHRwOi8vY3JsLmNvbW9kb2NhLmNvbS9DT01PRE9SU0FDbGllbnRBdXRoZW50aWNhdGlvbmFuZFNlY3VyZUVtYWlsQ0EuY3JsMIGLBggrBgEFBQcBAQR/MH0wVQYIKwYBBQUHMAKGSWh0dHA6Ly9jcnQuY29tb2RvY2EuY29tL0NPTU9ET1JTQUNsaWVudEF1dGhlbnRpY2F0aW9uYW5kU2VjdXJlRW1haWxDQS5jcnQwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmNvbW9kb2NhLmNvbTAgBgNVHREEGTAXgRVhc2Rhc2Rhc2Rhc2RkQGJ5b20uZGUwDQYJKoZIhvcNAQELBQADggEBAHEQTr0WFcwHVk0xozn26P3s6i3RWEcokNr8AdOtEvU0UYf1AfyVxUs04rS3Fs0lu2TD0840S3R687xF4HXhLYxSdD0QoZyUS2mgxxyVxCqhwptmLn7ZQjUKEuK6Kv6wZ3/XugsBoNrMYWlYX8g2jWVDBCJ+Z0eTQkaYkeSxzBSMQP3DxJS/bWh5LfwSyWYk4a3SVRJV4QVyBDXKt2uwjj1wWfxfGtiw6uAd2F3YIymZKsRVdrU6+h0gXMnmtpX8T+SDV6M72PP2/ZzF6gVVItyyrIScK1J8mcEaR5GGkLBk1s9qQM9esp3FRlACVeb1Qlytr4vgc5FlCqn0rMtjlF4=</ds:X509Certificate>
    --     </ds:X509Data>
    --   </ds:KeyInfo>
    --   <ds:Object Id="XadesObjectId-674a431e-692c-4e0a-9d82-6275c85c5876"><xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Id="QualifyingProperties-aa262416-8607-4f02-8897-0a6440a1ae03" Target="#Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --     <xades:SignedProperties Id="SignedProperties-Signature-d1cbfe99-fd8e-4e0f-b0b7-fc5bfe2f1dd0">
    --         <xades:SignedSignatureProperties>
    --             <xades:SigningTime>2018-06-19T18:44:02-0500</xades:SigningTime>
    --             <xades:SigningCertificate>
    --                 <xades:Cert>
    --                     <xades:CertDigest>
    --                         <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
    --                         <ds:DigestValue>b8Dptsa8ynvygBZYOLl2u6Nxn1RfzJlR44OmxEw+9ak=</ds:DigestValue>
    --                     </xades:CertDigest>
    --                     <xades:IssuerSerial>
    --                         <ds:X509IssuerName>C=GB, ST=Greater Manchester, L=Salford, O=COMODO CA Limited, CN=COMODO RSA Client Authentication and Secure Email CA</ds:X509IssuerName>
    --                         <ds:X509SerialNumber>40608093954460556376902031137928287845</ds:X509SerialNumber>
    --                     </xades:IssuerSerial>
    --                 </xades:Cert>
    --             </xades:SigningCertificate>
    --             <xades:SignaturePolicyIdentifier>
    --                 <xades:SignaturePolicyId>
    --                     <xades:SigPolicyId>
    --                         <xades:Identifier>https://tribunet.hacienda.go.cr/docs/esquemas/2017/v4.2/Resolucion%20Comprobantes%20Electronicos%20%20DGT-R-48-2016.pdf</xades:Identifier>
    --                         <xades:Description />
    --                     </xades:SigPolicyId>
    --                     <xades:SigPolicyHash>
    --                         <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
    --                         <ds:DigestValue>NmI5Njk1ZThkNzI0MmIzMGJmZDAyNDc4YjUwNzkzODM2NTBiOWUxNTBkMmI2YjgzYzZjM2I5NTZlNDQ4OWQzMQ==</ds:DigestValue>
    --                     </xades:SigPolicyHash>
    --                 </xades:SignaturePolicyId>
    --             </xades:SignaturePolicyIdentifier>
    --         </xades:SignedSignatureProperties>
    --         <xades:SignedDataObjectProperties>
    --             <xades:DataObjectFormat ObjectReference="#Reference-ab26afbd-e2dc-4cb0-886a-ce2a4a118c7f">
    --                 <xades:MimeType>text/xml</xades:MimeType>
    --                 <xades:Encoding>UTF-8</xades:Encoding>
    --             </xades:DataObjectFormat>
    --         </xades:SignedDataObjectProperties>
    --     </xades:SignedProperties>
    -- </xades:QualifyingProperties>
    -- </ds:Object>
    -- </ds:Signature></FacturaElectronica>
    -- 

    EXEC @hr = sp_OADestroy @cert
    EXEC @hr = sp_OADestroy @sbXml
    EXEC @hr = sp_OADestroy @gen
    EXEC @hr = sp_OADestroy @xml


END
GO

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.