It looks like the error is coming from the CSR itself rather than your API call. ZATCA’s simulation environment is quite strict about the CSR format, and there are a few common pitfalls:
Distinguished Name (DN) attributes
For CCSID requests, ZATCA expects the following DN fields in the CSR:
C → SA (Saudi Arabia)
O → Exact legal company name (ASCII)
CN → VAT number (for production use) or UUID (for sandbox/simulation).
Important: Make sure there are no extra spaces or special characters.
serialNumber → VAT number (without any prefixes like VAT:)
Optional fields like ST (state) and L (city) can usually be omitted in simulation, but it’s safer to include them if you have them.
CSR specifications
Key size: RSA 3072-bit (correct)
Hash: SHA256 (correct)
Key usage / Extended Key Usage: Make sure CodeSigning is actually included if you’re signing a code certificate. Sometimes using digitalSignature + keyEncipherment works better for ZATCA simulation.
Common issues
CN mismatch: If the CN does not exactly match the VAT or UUID format expected in the simulation, the CSR is rejected.
SerialNumber format: It must be exactly the VAT number digits, no letters, spaces, or dashes.
OpenSSL encoding: Ensure the CSR is PEM encoded and contains the standard -----BEGIN CERTIFICATE REQUEST----- headers.
Recommendation:
Try generating the CSR with the following OpenSSL command as a test (adjust CN and serialNumber as per your environment):