Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Create XAdES Facturae 3.2 Signed InvoiceSee more XAdES ExamplesDemonstrates how to create a factura electrónica XAdES digital signature for Gobierno de España Note: This example requires Chilkat v9.5.0.92 or greater. Problems specific to XML signatures for FacturaE in Spain were fixed in v9.5.0.92.
integer li_rc oleobject loo_XmlToSign oleobject loo_Gen integer li_Success oleobject loo_Object1 oleobject loo_Cert oleobject loo_SbXml // ---------------------------------------------------------------------- // IMPORTANT: This generated example requires Chilkat v9.5.0.75 or later. // Contact support@chilkatsoft.com for a pre-release. // ---------------------------------------------------------------------- // --- // The following source code can be generated from sample XML using the XML Signature Code Generator at chilkat.io // --- // IMPORTANT: This example requires Chilkat v9.5.0.92 or greater. Problems specific to XML signatures for FacturaE in Spain were fixed in v9.5.0.92. // Create the XML to be signed... loo_XmlToSign = create oleobject // Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 li_rc = loo_XmlToSign.ConnectToNewObject("Chilkat.Xml") if li_rc < 0 then destroy loo_XmlToSign MessageBox("Error","Connecting to COM object failed") return end if loo_XmlToSign.Tag = "fe:Facturae" loo_XmlToSign.AddAttribute("xmlns:ds","http://www.w3.org/2000/09/xmldsig#") loo_XmlToSign.AddAttribute("xmlns:fe","http://www.facturae.es/Facturae/2009/v3.2/Facturae") loo_XmlToSign.UpdateChildContent("FileHeader|SchemaVersion","3.2") loo_XmlToSign.UpdateChildContent("FileHeader|Modality","I") loo_XmlToSign.UpdateChildContent("FileHeader|InvoiceIssuerType","EM") loo_XmlToSign.UpdateChildContent("FileHeader|Batch|BatchIdentifier","0000000000B2Emit-") loo_XmlToSign.UpdateChildContent("FileHeader|Batch|InvoicesCount","1") loo_XmlToSign.UpdateChildContent("FileHeader|Batch|TotalInvoicesAmount|TotalAmount","63.13") loo_XmlToSign.UpdateChildContent("FileHeader|Batch|TotalOutstandingAmount|TotalAmount","63.13") loo_XmlToSign.UpdateChildContent("FileHeader|Batch|TotalExecutableAmount|TotalAmount","63.13") loo_XmlToSign.UpdateChildContent("FileHeader|Batch|InvoiceCurrencyCode","EUR") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|TaxIdentification|PersonTypeCode","J") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|TaxIdentification|ResidenceTypeCode","R") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|TaxIdentification|TaxIdentificationNumber","A82735122") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|CorporateName","Company Comp SA") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|TradeName","Comp") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|RegistrationData|Book","1") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|RegistrationData|RegisterOfCompaniesLocation","12AP22") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|RegistrationData|Sheet","3") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|RegistrationData|Folio","15") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|RegistrationData|Section","2") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|RegistrationData|Volume","12") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|RegistrationData|AdditionalRegistrationData","Sin datos") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|AddressInSpain|Address","C/ Mayour 33 15 E") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|AddressInSpain|PostCode","28001") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|AddressInSpain|Town","Argamasilla de Alba") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|AddressInSpain|Province","Ciudad Real") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|AddressInSpain|CountryCode","ESP") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|ContactDetails|Telephone","917776665") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|ContactDetails|TeleFax","917776666") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|ContactDetails|WebAddress","www.facturae.es") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|ContactDetails|ElectronicMail","facturae@mityc.es") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|ContactDetails|ContactPersons","Fernando") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|ContactDetails|CnoCnae","28000") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|ContactDetails|INETownCode","2134AAB") loo_XmlToSign.UpdateChildContent("Parties|SellerParty|LegalEntity|ContactDetails|AdditionalContactDetails","Otros datos") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|TaxIdentification|PersonTypeCode","F") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|TaxIdentification|ResidenceTypeCode","E") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|TaxIdentification|TaxIdentificationNumber","0000000000B") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|CentreCode","1") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|RoleTypeCode","02") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|Name","Ruth") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|FirstSurname","Mauripo") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|Address","Armenia 1922") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|PostCodeAndTown","00000 Buenos Aires") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|Province","Capital Federal") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|OverseasAddress|CountryCode","ARG") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|AdministrativeCentres|AdministrativeCentre|CentreDescription","Centro principal de recepcion") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|Individual|Name","Juana") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|Individual|FirstSurname","Mauripo") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|Individual|OverseasAddress|Address","Juncal 1315") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|Individual|OverseasAddress|PostCodeAndTown","00000 Buenos Aires") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|Individual|OverseasAddress|Province","Capital Federal") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|Individual|OverseasAddress|CountryCode","ARG") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|Individual|ContactDetails|Telephone","00547775554") loo_XmlToSign.UpdateChildContent("Parties|BuyerParty|Individual|ContactDetails|TeleFax","00547775555") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceHeader|InvoiceNumber","2") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceHeader|InvoiceSeriesCode","Emit-") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceHeader|InvoiceDocumentType","FC") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceHeader|InvoiceClass","OO") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|IssueDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|OperationDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|PlaceOfIssue|PostCode","00000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|PlaceOfIssue|PlaceOfIssueDescription","Regalos") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|InvoicingPeriod|StartDate","2010-03-09") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|InvoicingPeriod|EndDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|InvoiceCurrencyCode","EUR") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|TaxCurrencyCode","EUR") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceIssueData|LanguageName","es") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax|TaxTypeCode","01") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax|TaxRate","16.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax|TaxableBase|TotalAmount","26.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax|TaxAmount|TotalAmount","4.16") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax|EquivalenceSurcharge","1.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax|EquivalenceSurchargeAmount|TotalAmount","0.26") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax[1]|TaxTypeCode","01") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax[1]|TaxRate","0.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesOutputs|Tax[1]|TaxableBase|TotalAmount","0.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesWithheld|Tax|TaxTypeCode","05") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesWithheld|Tax|TaxRate","4.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesWithheld|Tax|TaxableBase|TotalAmount","26.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|TaxesWithheld|Tax|TaxAmount|TotalAmount","1.04") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|TotalGrossAmount","59.75") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|TotalGeneralDiscounts","0.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|TotalGeneralSurcharges","0.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|TotalGrossAmountBeforeTaxes","59.75") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|TotalTaxOutputs","4.42") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|TotalTaxesWithheld","1.04") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|InvoiceTotal","63.13") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|TotalOutstandingAmount","63.13") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|InvoiceTotals|TotalExecutableAmount","63.13") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|IssuerContractReference","A9938281") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|IssuerContractDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|IssuerTransactionReference","A9938282") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|IssuerTransactionDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|ReceiverContractReference","BBBH-38271") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|ReceiverContractDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|ReceiverTransactionReference","BBBH-38272") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|ReceiverTransactionDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|FileReference","000298172") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|FileDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|SequenceNumber","1.0") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote|DeliveryNoteNumber","132413842") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote|DeliveryNoteDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote[1]|DeliveryNoteNumber","987673211") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|DeliveryNotesReferences|DeliveryNote[1]|DeliveryNoteDate","2010-03-09") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|ItemDescription","Flores") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|Quantity","1.0") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|UnitOfMeasure","01") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|UnitPriceWithoutTax","25.000000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|TotalCost","25.000000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountReason","Descuento") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountRate","5.0000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|DiscountsAndRebates|Discount|DiscountAmount","1.250000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|Charges|Charge|ChargeReason","Cargo") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|Charges|Charge|ChargeAmount","10.000000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|GrossAmount","33.750000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxTypeCode","01") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxRate","0.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxableBase|TotalAmount","0.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|TaxesOutputs|Tax|TaxAmount|TotalAmount","0.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|AdditionalLineItemInformation","Contacto en Neuquen: Paulita") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|SpecialTaxableEvent|SpecialTaxableEventCode","01") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|SpecialTaxableEvent|SpecialTaxableEventReason","Concepto exento por el motivo aqu definido") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine|ArticleCode","142") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|IssuerContractDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|IssuerTransactionDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|ReceiverContractDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|ReceiverTransactionDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|FileDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|SequenceNumber","2.0") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|ItemDescription","Mate") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|Quantity","2.0") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|UnitOfMeasure","01") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|UnitPriceWithoutTax","13.000000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TotalCost","26.000000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|GrossAmount","26.000000") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxTypeCode","05") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxRate","4.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxableBase|TotalAmount","26.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesWithheld|Tax|TaxAmount|TotalAmount","1.04") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxTypeCode","01") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxRate","16.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxableBase|TotalAmount","26.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|TaxAmount|TotalAmount","4.16") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|EquivalenceSurcharge","1.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|TaxesOutputs|Tax|EquivalenceSurchargeAmount|TotalAmount","0.26") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|Items|InvoiceLine[1]|ArticleCode","122") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|InstallmentDueDate","2010-03-10") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|InstallmentAmount","25.00") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|PaymentMeans","19") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|IBAN","4322 3432 22 1341234212") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|BankCode","4322") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|BranchCode","3432") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|Address","Juncal 1423 8 Z") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|PostCodeAndTown","01115 Capital Federal") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|Province","Buenos Aires") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeCredited|OverseasBranchAddress|CountryCode","ARG") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|PaymentReconciliationReference","12223") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|IBAN","1234 4312 22 33212341212314") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|BankCode","1234") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|AccountToBeDebited|BranchCode","4312") loo_XmlToSign.UpdateChildContent("Invoices|Invoice|PaymentDetails|Installment|DebitReconciliationReference","12223") loo_Gen = create oleobject // Use "Chilkat_9_5_0.XmlDSigGen" for versions of Chilkat < 10.0.0 li_rc = loo_Gen.ConnectToNewObject("Chilkat.XmlDSigGen") li_Success = 1 loo_Gen.SigLocation = "fe:Facturae" loo_Gen.SigLocationMod = 0 loo_Gen.SigId = "Signature869123" loo_Gen.AddSignatureNamespace("etsi","http://uri.etsi.org/01903/v1.3.2#") loo_Gen.SigNamespacePrefix = "ds" loo_Gen.SigNamespaceUri = "http://www.w3.org/2000/09/xmldsig#" loo_Gen.SignedInfoId = "Signature-SignedInfo241096" loo_Gen.SignedInfoCanonAlg = "EXCL_C14N" loo_Gen.SignedInfoDigestMethod = "sha256" // Create an Object to be added to the Signature. loo_Object1 = create oleobject // Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 li_rc = loo_Object1.ConnectToNewObject("Chilkat.Xml") loo_Object1.Tag = "xades:QualifyingProperties" loo_Object1.AddAttribute("xmlns:xades","http://uri.etsi.org/01903/v1.3.2#") // The Id can be any unique string.. loo_Object1.AddAttribute("Id","QualifyingProperties-e01a8fee-1bee-4ff5-9570-3d57aa02f278") loo_Object1.AddAttribute("Target","#Signature869123") loo_Object1.UpdateAttrAt("xades:SignedProperties",1,"Id","Signature869123-SignedProperties787205") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningTime","TO BE GENERATED BY CHILKAT") // Note: It may be that http://www.w3.org/2001/04/xmlenc#sha256 is needed in the following line instead of http://www.w3.org/2000/09/xmldsig#sha1 loo_Object1.UpdateAttrAt("xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestMethod",1,"Algorithm","http://www.w3.org/2000/09/xmldsig#sha1") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestValue","TO BE GENERATED BY CHILKAT") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509IssuerName","TO BE GENERATED BY CHILKAT") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509SerialNumber","TO BE GENERATED BY CHILKAT") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier","http://www.facturae.es/politica_de_firma_formato_facturae/politica_de_firma_formato_facturae_v3_1.pdf") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Description","Pol�tica de Firma FacturaE v3.1") loo_Object1.UpdateAttrAt("xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestMethod",1,"Algorithm","http://www.w3.org/2000/09/xmldsig#sha1") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue","Ohixl6upD6av8N7pEvDABhEL6hM=") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedSignatureProperties|xades:SignerRole|xades:ClaimedRoles|xades:ClaimedRole","emisor") loo_Object1.UpdateAttrAt("xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat",1,"ObjectReference","#Reference-ID-670821") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Description","Factura electr�nica") loo_Object1.UpdateChildContent("xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:MimeType","text/xml") loo_Gen.AddObject("Signature869123-Object629337",loo_Object1.GetXml(),"","") loo_Gen.AddObjectRef("Signature869123-SignedProperties787205","sha1","","","http://uri.etsi.org/01903#SignedProperties") loo_Gen.SetRefIdAttr("Signature869123-SignedProperties787205","SignedPropertiesID459347") loo_Gen.KeyInfoId = "Certificate1570061" loo_Gen.AddSameDocRef("Certificate1570061","sha1","","","") loo_Gen.AddSameDocRef("","sha1","","","") loo_Gen.SetRefIdAttr("","Reference-ID-670821") // Provide a certificate + private key. (PFX password is test123) loo_Cert = create oleobject // Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0 li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert") li_Success = loo_Cert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123") if li_Success <> 1 then Write-Debug loo_Cert.LastErrorText destroy loo_XmlToSign destroy loo_Gen destroy loo_Object1 destroy loo_Cert return end if loo_Gen.SetX509Cert(loo_Cert,1) loo_Gen.KeyInfoType = "X509Data+KeyValue" loo_Gen.X509Type = "Certificate" // Load XML to be signed... loo_SbXml = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbXml.ConnectToNewObject("Chilkat.StringBuilder") loo_XmlToSign.GetXmlSb(loo_SbXml) loo_Gen.Behaviors = "CompactSignedXml" // Sign the XML... li_Success = loo_Gen.CreateXmlDSigSb(loo_SbXml) if li_Success <> 1 then Write-Debug loo_Gen.LastErrorText destroy loo_XmlToSign destroy loo_Gen destroy loo_Object1 destroy loo_Cert destroy loo_SbXml return end if // Save the signed XMl to a file. li_Success = loo_SbXml.WriteFile("qa_output/signedXml.xml","utf-8",0) Write-Debug loo_SbXml.GetAsString() destroy loo_XmlToSign destroy loo_Gen destroy loo_Object1 destroy loo_Cert destroy loo_SbXml |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.