Architectural Purpose: What Problem Does a CSID Solve?
Before Phase 2, electronic invoices in Saudi Arabia were vulnerable to retroactive data tampering, backdating, and unauthorized alterations because PDF and text formats lacked immutable digital signatures.
Under Phase 2, ZATCA introduced a national Public Key Infrastructure (PKI). The CSID establishes non-repudiation and cryptographic integrity:
Keypair Generation
EGS unit generates a private key (held securely locally) and a public key (embedded in CSR)
ZATCA CA Signing
ZATCA's Trust Sub-CA cryptographically signs the public key and returns the CSID certificate
Digital Invoice Signing
EGS signs each outgoing UBL 2.1 XML document using its private key; embeds CSID in XML
ZATCA Cloud Verification
ZATCA receives the invoice, verifies the signature against the active CSID, and clears the transaction
Through this mechanism, ZATCA can mathematically verify that an invoice was generated by an authorized, registered machine and has not been altered by a single byte since generation.
Comprehensive Comparison: Compliance CSID vs Production CSID
Developers and ERP integrators frequently confuse the roles and capabilities of the two certificate types. The following matrix outlines their critical differences:
| Architectural Dimension | Compliance CSID (CCSID) | Production CSID (PCSID) | Renewal CSID (RCSID) |
|---|---|---|---|
| Primary Objective | Validate software technical capability and schema conformance. | Issue legal, tax-deductible commercial tax invoices. | Extend validity of an existing onboarded EGS unit before expiration. |
| Issuance Trigger | Generated via /compliance endpoint using a 60-minute Fatoora Portal OTP. | Granted via /production/csids after 100% compliance test pass rate. | Issued via /production/csids using the active unexpired Production CSID. |
| Allowed Environments | Simulation Sandbox and Compliance Engine. | Live Production Gateway (/e-invoicing/core). | Live Production Gateway (/e-invoicing/core). |
| Legal Validity of Invoices | Zero. Strictly for test validation. | 100% Legal. Permitted for commercial billing. | 100% Legal. Seamless continuation. |
| Supported Operations | Sample invoice clearance and reporting checks. | Live B2B clearance, live B2C reporting, credit/debit notes. | Continues live operations without billing interruption. |
| Certificate Lifespan | Temporary (expires once compliance checks complete or stall). | 5 Years from issuance date. | 5 Years from renewal issuance date. |
| API Endpoints Accessible | /compliance/invoices, /production/csids. | /invoices/clearance/single, /invoices/reporting/single. | Same as Production CSID. |
Inside the CSID: X.509 Certificate Structure & Custom OIDs
A ZATCA CSID is not a standard web server SSL certificate. It is tailored with specific Object Identifiers (OIDs) mandated by Saudi e-invoicing standards:
Key Technical Parameters of the Certificate
secp256k1 (standard Koblitz curve, 256-bit prime field)Statutory Safeguards & Rights Protection
Mandatory protections enforced by MHRSD & Saudi Labor Law
If any of these fields are missing or improperly formatted during the CSR generation phase, ZATCA's compliance gateway automatically rejects the request with HTTP error 400 Bad Request: Invalid Subject DN.
How the CSID is Used in Live Invoicing Transactions
Once an enterprise secures a Production CSID, the certificate is utilized across two distinct technical workflows:
Workflow 1: Invoice Digital Signing (XML Payload)
When the ERP generates an electronic invoice according to the UBL 2.1 XML schema:
<ds:Signature> element inside the UBL 2.1 XML.Workflow 2: API Authentication (HTTP Basic Auth)
When transmitting the signed XML to ZATCA's cloud gateway for clearance or reporting:
binarySecurityToken (CSID) and the associated secret.binarySecurityToken:secret.Authorization header: Authorization: Basic TVRJRnFEQ0N...[BASE64_CREDENTIALS]...Certificate Storage & Cryptographic Custody Requirements
Under ZATCA regulations, taxpayers bear strict statutory liability for the security and custody of their cryptographic credentials:
Secure Key Generation
Private keys must be generated inside secure enterprise hardware or encrypted environments
Restricted Access Vault
Private keys must NEVER be transmitted over networks, shared with vendors, or logged in text files
Dedicated EGS Binding
A single CSID must never be duplicated across multiple physical cash registers or retail stores
Tamper-Proof Audit Log
Every invoice signature event must be permanently recorded with an incremental counter (ICV)
Severe Penalties for Key Leakage:
Leaking or sharing your EGS private key is treated under Saudi law as a critical security breach. Any unauthorized tax invoices generated with your CSID will be legally attributed to your enterprise, resulting in immediate tax assessments and potential anti-fraud investigations.
The CSID Renewal & Revocation Lifecycle
A Production CSID does not last indefinitely. Enterprisewide IT governance must account for certificate rotation:
1. Routine Renewal (Prior to 5-Year Expiration)
Enterprises should initiate renewal 30 to 60 days before the 5-year expiration date.
/production/csids endpoint using its existing, active Production CSID for authentication.2. Immediate Revocation Scenarios
An enterprise must immediately revoke a CSID via the Fatoora Portal dashboard under the following conditions:
Common CSID Errors & Developer Fixes
| Error Code / Message | Underlying Cause | Developer Resolution |
|---|---|---|
| `401 Unauthorized: Invalid Certificate` | The API request is using a Compliance CSID on the production /core endpoint. | Complete the compliance step and promote the certificate to a Production CSID via /production/csids. |
| `Signature Value Verification Failed` | The private key used to sign the invoice does not match the public key in the CSID. | Verify that the ERP is signing with the exact private key that generated the onboarded CSR. |
| `Invalid Basic Auth Format` | Trailing whitespace or newline characters inside the Base64-encoded binarySecurityToken:secret header. | Strip all newline characters (\r\n) from the token and secret strings prior to Base64 encoding. |
| `Certificate Revoked` | The CSID was manually deactivated on the Fatoora Portal by company administration. | Generate a fresh OTP on the portal and re-run the complete onboarding pipeline. |
| `400 Bad Request: Missing OID 0.9.2342...` | The CSR was generated without the mandatory Taxpayer VAT Number OID. | Update the OpenSSL req_extensions configuration file to include the required ZATCA custom OIDs. |
Frequently Asked Questions (FAQ)
Can a single company have more than one CSID?
Yes. In fact, large enterprises typically operate dozens or hundreds of CSIDs. Every distinct physical POS terminal, individual cash register, or separate ERP billing node must possess its own unique serial number and dedicated CSID.
Does a CSID need to be renewed if the company changes its business address?
Yes. Because the physical branch location is cryptographically embedded into the Subject Distinguished Name of the CSID certificate, updating your commercial address requires generating a new CSR and re-onboarding the EGS unit.
Can an ERP vendor onboard a CSID on behalf of a taxpayer?
An ERP vendor can assist with the technical execution, but the taxpayer's authorized representative must log into the Fatoora Portal via Nafath/ERAD to generate the mandatory 6-digit OTP.
Is the CSID certificate visible to consumers on printed invoices?
No. The full CSID certificate is not printed in text on paper receipts. However, the cryptographic stamp derived from the CSID is encoded within the mandatory Base64 QR code on simplified B2C invoices and embedded in the XML of B2B invoices.
What happens if an invoice is submitted after the Production CSID expires?
The ZATCA clearance engine will immediately reject the transaction with an HTTP 401 Unauthorized / CERTIFICATE_EXPIRED error. The invoice will be legally invalid, and customers will be unable to claim VAT input deductions until the certificate is renewed.
Was this compliance guide helpful?
Your feedback helps our legal editorial team maintain authoritative KSA guidance.
Advocate High Court (Punjab Bar Council) and ATT GCC VAT Certified Specialist. Author of comprehensive regulatory commentaries on Saudi corporate law, ZATCA e-invoicing protocols, and Labor Reform Initiatives.