Signature validation errors : CODE : signatureValue, MESSAGE : wrong signature Value

Subject: Issue with OTP Activation in Simulation Mode and Signature Validation Errors

Description:

Hello,

I have activated the OTP feature in Simulation Mode and successfully obtained the OTP. However, I am encountering the following error when submitting the request:

yaml

Copy code

signature validation errors:  
CODE: signatureValue, MESSAGE: wrong signature value  

Details:

  • I am using the ZATCA E-Invoice Java SDK (Version 2.3.0).
  • Below is the XML file I am using for the request. I would like to know if there is any issue with the XML structure or content that might be causing this error.

xml

Copy code

[Insert XML file content here]

Questions:

  1. Is there any issue with the provided XML file that could result in the signature validation error?
  2. Are there additional steps or configurations required when using the ZATCA SDK to ensure the signature is correctly validated?

Your assistance would be greatly appreciated. That is XML File
<?xml version="1.0" encoding="UTF-8"?> <Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"><ext:UBLExtensions> <ext:UBLExtension> <ext:ExtensionURI>urn:oasis:names:specification:ubl:dsig:enveloped:xades</ext:ExtensionURI> <ext:ExtensionContent> <sig:UBLDocumentSignatures xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2" xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2" xmlns:sbc="urn:oasis:names:specification:ubl:schema:xsd:SignatureBasicComponents-2"> <sac:SignatureInformation> <cbc:ID>urn:oasis:names:specification:ubl:signature:1</cbc:ID> <sbc:ReferencedSignatureID>urn:oasis:names:specification:ubl:signature:Invoice</sbc:ReferencedSignatureID> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="signature"> <ds:SignedInfo> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2006/12/xml-c14n11"/> <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"/> <ds:Reference Id="invoiceSignedData" URI=""> <ds:Transforms> <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"> <ds:XPath>not(//ancestor-or-self::ext:UBLExtensions)</ds:XPath> </ds:Transform> <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"> <ds:XPath>not(//ancestor-or-self::cac:Signature)</ds:XPath> </ds:Transform> <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"> <ds:XPath>not(//ancestor-or-self::cac:AdditionalDocumentReference[cbc:ID='QR'])</ds:XPath> </ds:Transform> <ds:Transform Algorithm="http://www.w3.org/2006/12/xml-c14n11"/> </ds:Transforms> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> <ds:DigestValue>SsuuIHaaHWtgBPeTh350m8LQ7yEVR828mgd7LoG3V10=</ds:DigestValue> </ds:Reference> <ds:Reference Type="http://www.w3.org/2000/09/xmldsig#SignatureProperties" URI="#xadesSignedProperties"> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> <ds:DigestValue>YjYwYTY5NTdiODBjMTVkMDliZTVhNmIyY2U1Zjk4MDY1YzUwNGFjNWIwYzVhMDU0ZDQxMGM1ZGZiNjZlMzczMA==</ds:DigestValue> </ds:Reference> </ds:SignedInfo> <ds:SignatureValue>MEQCIFdiL3RYnEb7BXrJzgD+bfo0uSw4+xCBK3DkO1gghqyQAiBPlus4sbfy7dAPiKKpNO3UYYuOoG7GmOfDv8CaZ+6uTg==</ds:SignatureValue> <ds:KeyInfo> <ds:X509Data> <ds:X509Certificate>LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQzakNDQTRTZ0F3SUJBZ0lURVFBQU9BUEY5MEFqcy94Y1h3QUJBQUE0QXpBS0JnZ3Foa2pPUFFRREFqQmlNUlV3RXdZS0NaSW1pWlB5TEdRQkdSWUZiRzlqWVd3eEV6QVJCZ29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kZwWVRRdWVtRjBZMkV1WjI5MkxuTmhMME5sY25SRmJuSnZiR3d2VUZKYVJVbHVkbTlwWTJWVFEwRTBMbVY0ZEdkaGVuUXVaMjkyTG14dlkyRnNYMUJTV2tWSlRsWlBTVU5GVTBOQk5DMURRU2d4S1M1amNuUXdEZ1lEVlIwUEFRSC9CQVFEQWdlQU1Ed0dDU3NHQVFRQmdqY1ZCd1F2TUMwR0pTc0dBUVFCZ2pjVkNJR0dxQjJFMFBzU2h1MmRKSWZPK3huVHdGVm1oL3FsWllYWmhENENBV1FDQVJJd0hRWURWUjBsQkJZd0ZBWUlLd1lCQlFVSEF3TUdDQ3NHQVFVRkJ3TUNNQ2NHQ1NzR0FRUUJnamNWQ2dRYU1CZ3dDZ1lJS3dZQkJRVUhBd013Q2dZSUt3WUJCUVVIQXdJd0NnWUlLb1pJemowRUF3SURTQUF3UlFJaEFMRS9pY2htbldYQ1VLVWJjYTN5Y2k4b3F3YUx2RmRIVmpRcnZlSTl1cUFiQWlBOWhDNE04amdNQkFEUFN6bWQydWlQSkE2Z0tSM0xFMDNVNzVlcWJDL3JYQT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=</ds:X509Certificate> </ds:X509Data> </ds:KeyInfo> <ds:Object> <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="signature"> <xades:SignedProperties Id="xadesSignedProperties"> <xades:SignedSignatureProperties> <xades:SigningTime>2024-12-05T14:15:02</xades:SigningTime> <xades:SigningCertificate> <xades:Cert> <xades:CertDigest> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> <ds:DigestValue>YWMxMjk4MTBhNmExYzgyNTY3OTZjM2FmNWY0ODFmZTJjMTIxNWZlZjYxMzJhNTcyODZlOWM2NzBmNDZiMjdiMg==</ds:DigestValue> </xades:CertDigest> <xades:IssuerSerial> <ds:X509IssuerName>CN=PRZEINVOICESCA4-CA, DC=extgazt, DC=gov, DC=local</ds:X509IssuerName> <ds:X509SerialNumber>379112742831380471835263969587287663520528387</ds:X509SerialNumber> </xades:IssuerSerial> </xades:Cert> </xades:SigningCertificate> </xades:SignedSignatureProperties> </xades:SignedProperties> </xades:QualifyingProperties> </ds:Object> </ds:Signature> </sac:SignatureInformation> </sig:UBLDocumentSignatures> </ext:ExtensionContent> </ext:UBLExtension> </ext:UBLExtensions> <cbc:ProfileID>reporting:1.0</cbc:ProfileID> <cbc:ID>PV-I241205006</cbc:ID> <cbc:UUID>1fd6a993-9567-4a24-8d74-1ba90304f6d2</cbc:UUID> <cbc:IssueDate>2024-12-05</cbc:IssueDate> <cbc:IssueTime>17:15:01</cbc:IssueTime> <cbc:InvoiceTypeCode name="0200000">388</cbc:InvoiceTypeCode> <cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode> <cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode> <cac:AdditionalDocumentReference> <cbc:ID>ICV</cbc:ID> <cbc:UUID>3</cbc:UUID> </cac:AdditionalDocumentReference> <cac:AdditionalDocumentReference> <cbc:ID>PIH</cbc:ID> <cac:Attachment> <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">GfYbTIggIWa+U7M/OAWWouHzXWHkTSvWc7x6FtBmOE0=</cbc:EmbeddedDocumentBinaryObject> </cac:Attachment> </cac:AdditionalDocumentReference> <cac:AdditionalDocumentReference> <cbc:ID>QR</cbc:ID> <cac:Attachment> <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">AQREZW1vAg8zMDA0MTg4MDg5MDAwMDMDEzIwMjQtMTItMDVUMTc6MTU6MDEEBDU4LjAFAzcuNQYsU3N1dUlIYWFIV3RnQlBlVGgzNTBtOExRN3lFVlI4MjhtZ2Q3TG9HM1YxMD0HYE1FUUNJRmRpTDNSWW5FYjdCWHJKemdEK2JmbzB1U3c0K3hDQkszRGtPMWdnaHF5UUFpQlBsdXM0c2JmeTdkQVBpS0twTk8zVVlZdU9vRzdHbU9mRHY4Q2FaKzZ1VGc9PQhYMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEoWCKa0Sa9FIErTOv0uAkC1VIKXxU9nPpx2vlf4yhMejy8c02XJblDq7tPydo8mq0ahOMmNo8gwni7Xt1KT9UeAlHMEUCIQCxP4nIZp1lwlClG3Gt8nIvKKsGi7xXR1Y0K73iPbqgGwIgPYQuDPI4DAQAz0s5ndrojyQOoCkdyxNN1O+Xqmwv61w=</cbc:EmbeddedDocumentBinaryObject> </cac:Attachment> </cac:AdditionalDocumentReference><cac:Signature> <cbc:ID>urn:oasis:names:specification:ubl:signature:Invoice</cbc:ID> <cbc:SignatureMethod>urn:oasis:names:specification:ubl:dsig:enveloped:xades</cbc:SignatureMethod> </cac:Signature><cac:AccountingSupplierParty> <cac:Party> <cac:PartyIdentification> <cbc:ID schemeID="CRN">2050196330</cbc:ID> </cac:PartyIdentification> <cac:PostalAddress> <cbc:StreetName>test</cbc:StreetName> <cbc:BuildingNumber>1234</cbc:BuildingNumber> <cbc:CitySubdivisionName>{{ no such element: dict object['city_subdivision_name'] }}</cbc:CitySubdivisionName> <cbc:CityName>DAMMAM</cbc:CityName> <cbc:PostalZone>00966</cbc:PostalZone> <cac:Country> <cbc:IdentificationCode>SA</cbc:IdentificationCode> </cac:Country> </cac:PostalAddress> <cac:PartyTaxScheme> <cbc:CompanyID>300418808900003</cbc:CompanyID> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:PartyTaxScheme> <cac:PartyLegalEntity> <cbc:RegistrationName>Demo</cbc:RegistrationName> </cac:PartyLegalEntity> </cac:Party> </cac:AccountingSupplierParty> <cac:AccountingCustomerParty> <cac:Party> <cac:PostalAddress> <cbc:StreetName>Dammam</cbc:StreetName> <cbc:BuildingNumber>2123</cbc:BuildingNumber> <cbc:CityName>Dammam</cbc:CityName> <cbc:PostalZone>00966</cbc:PostalZone> <cac:Country> <cbc:IdentificationCode>SA</cbc:IdentificationCode> </cac:Country> </cac:PostalAddress> <cac:PartyLegalEntity> <cbc:RegistrationName>شركة حرير حقيقي التجارية</cbc:RegistrationName> </cac:PartyLegalEntity> </cac:Party> </cac:AccountingCustomerParty> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>Discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">0.0</cbc:Amount> <cac:TaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>15.0</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:AllowanceCharge> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">7.5</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="SAR">50.0</cbc:TaxableAmount> <cbc:TaxAmount currencyID="SAR">7.5</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>15.0</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">7.5</cbc:TaxAmount> </cac:TaxTotal> <cac:LegalMonetaryTotal> <cbc:LineExtensionAmount currencyID="SAR">50.0</cbc:LineExtensionAmount> <cbc:TaxExclusiveAmount currencyID="SAR">50.0</cbc:TaxExclusiveAmount> <cbc:TaxInclusiveAmount currencyID="SAR">57.5</cbc:TaxInclusiveAmount> <cbc:AllowanceTotalAmount currencyID="SAR">0.0</cbc:AllowanceTotalAmount> <cbc:PayableRoundingAmount currencyID="SAR">0.5</cbc:PayableRoundingAmount> <cbc:PayableAmount currencyID="SAR">58.0</cbc:PayableAmount> </cac:LegalMonetaryTotal> <cac:InvoiceLine> <cbc:ID>1</cbc:ID> <cbc:InvoicedQuantity unitCode="PCE">1.0</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="SAR">50.0</cbc:LineExtensionAmount> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">7.5</cbc:TaxAmount> <cbc:RoundingAmount currencyID="SAR">57.5</cbc:RoundingAmount> </cac:TaxTotal> <cac:Item> <cbc:Name>test2</cbc:Name> <cac:ClassifiedTaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>15.0</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:ClassifiedTaxCategory> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="SAR">50.0</cbc:PriceAmount> <cbc:BaseQuantity unitCode="PCE">1.0</cbc:BaseQuantity> </cac:Price> </cac:InvoiceLine> </Invoice>

Dear @working123,

Thanks for reaching out.

To provide comprehensive support as usual, can I kindly ask you the below:

  1. The steps that you followed in the singing process.
  2. The invoice type standard or simplified.

Best regards,
Lina

I Create CSR And Create CSID use ZATCA SDK and sign to stander invoice

nvoice type is standard

Dear @working123,

Thank you for getting back to us.

Please note that the signing process is not required for standard (B2B) invoices. It is mandatory only for simplified (B2C) invoices.

Additionally, to ensure seamless functionality and alignment with ZATCA’s requirements, we recommend installing the latest version of the SDK, which is now 3.3.9. This version includes updates and improvements to support all recent business rule enhancements.

If you have any further questions or require additional clarification, please don’t hesitate to reach out.

Best regards,