When i wan to generate csid i am getting this error

Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Program.$(String args) in C:\Users\Ishaa\source\repos\CSID\CSID\Program.cs:line 17
at Program.(String args)

C:\Users\Ishaa\source\repos\CSID\CSID\bin\Debug\net8.0\CSID.exe (process 22680) exited with code -532462766 (0xe0434352).
Press any key to close this window . . .

Dear @aljabri

Kindly provide all of the details and screenshot of the error to ensure a comprehensive support.

Please Share via below emails:

sp_support@zatca.gov.sa
E-invoicing@zatca.gov.sa

Thank you.

we already emailed on the above emails … waiting for reply. still if you can guide us on the issue it will help.

A) Create a config.cnf file

oid_section = OIDs
[ OIDs ]
certificateTemplateName= 1.3.6.1.4.1.1311.20.2

[ req ]
default_bits = 2048
emailAddress = aljabri@aljabrisoft.com
req_extensions = v3_req
x509_extensions = v3_ca
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn

[ dn ]
C=SA
OU=Jeddah
O=AlJabrisoft
CN=Jeddah

[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment

[req_ext]
certificateTemplateName = ASN1:PRINTABLESTRING:PREZATCA-Code-Signing
subjectAltName = dirName:alt_names

[alt_names]
SN=334562332454545
UID=300000000000003
title=1100
registeredAddress=Jeddah
businessCategory=Software

B) Open Cmd and run the following commands to create private key, public key and my.csr

1- Create private key
openssl ecparam -name secp256k1 -genkey -noout -out ec-secp256k1-priv-key.pem

2- Create public key
openssl ec -in ec-secp256k1-priv-key.pem -pubout > ec-secp256k1-pub-key.pem

3- Create CSR
openssl req -new -sha256 -key ec-secp256k1-priv-key.pem -extensions v3_req -config config.cnf -out my.csr

C) Convert my.csr to Encode to Base64 format
output:
TUlJQkpUQ0J6UUlCQURCRk1Rc3dDUVlEVlFRR0V3SlRRVEVQTUEwR0ExVUVDd3dHU21Wa1pHRm9NUlF3RWdZRApWUVFLREF0QmJFcGhZbkpwYzI5bWRERVBNQTBHQTFVRUF3d0dTbVZrWkdGb01GWXdFQVlIS29aSXpqMENBUVlGCks0RUVBQW9EUWdBRTVLSEQvN3FVMEdyL3c1Qmo1Y0FXaFhldWRWc0c2MUlDT2xxYmlPUE5LcTVqZmFDeDJyRmYKeTVyYW5wWndaRll1ZWQyRFg4bjFPQlhKYXhPek1QTUNGNkFwTUNjR0NTcUdTSWIzRFFFSkRqRWFNQmd3Q1FZRApWUjBUQkFJd0FEQUxCZ05WSFE4RUJBTUNCZUF3Q2dZSUtvWkl6ajBFQXdJRFJ3QXdSQUlnU3ZSY1BrWXJXc21NCjI4K0tmcFZiaXBCbHBHcGVGZzNraWNGU1VGYWY1ME1DSUQzZnppajE1QnBkUHdPaitsNVJQM1FwVEpwSlZQWHQKQjNFdHdob1lzd1lC

D) Get The OTP from the fatoora.zatca.gov.sa → 425204

E) Run the visual studio program.cs file add the OTP and base64 output to get CSID
Code:

using System.Net.Http;
using System.Net.Http.Headers;

HttpClient client = new HttpClient();

HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, “https://gw-fatoora.zatca.gov.sa/e-invoicing/developer-portal/compliance”);

request.Headers.Add(“accept”, “application/json”);
request.Headers.Add(“OTP”, “425204”);
request.Headers.Add(“Accept-Version”, “V2”);

request.Content = new StringContent(“{\n "csr": "TUlJQkpUQ0J6UUlCQURCRk1Rc3dDUVlEVlFRR0V3SlRRVEVQTUEwR0ExVUVDd3dHU21Wa1pHRm9NUlF3RWdZRApWUVFLREF0QmJFcGhZbkpwYzI5bWRERVBNQTBHQTFVRUF3d0dTbVZrWkdGb01GWXdFQVlIS29aSXpqMENBUVlGCks0RUVBQW9EUWdBRTVLSEQvN3FVMEdyL3c1Qmo1Y0FXaFhldWRWc0c2MUlDT2xxYmlPUE5LcTVqZmFDeDJyRmYKeTVyYW5wWndaRll1ZWQyRFg4bjFPQlhKYXhPek1QTUNGNkFwTUNjR0NTcUdTSWIzRFFFSkRqRWFNQmd3Q1FZRApWUjBUQkFJd0FEQUxCZ05WSFE4RUJBTUNCZUF3Q2dZSUtvWkl6ajBFQXdJRFJ3QXdSQUlnU3ZSY1BrWXJXc21NCjI4K0tmcFZiaXBCbHBHcGVGZzNraWNGU1VGYWY1ME1DSUQzZnppajE1QnBkUHdPaitsNVJQM1FwVEpwSlZQWHQKQjNFdHdob1lzd1lC"\n}”);

request.Content.Headers.ContentType = new MediaTypeHeaderValue(“application/json”);

HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();

F) Execution Output :

Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (Bad Request).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Program.$(String args) in C:\Users\Ishaa\source\repos\CSID\CSID\Program.cs:line 17
at Program.(String args)

C:\Users\Ishaa\source\repos\CSID\CSID\bin\Debug\net8.0\CSID.exe (process 22680) exited with code -532462766 (0xe0434352).
Press any key to close this window . . .

Dear @aljabri

Thanks for reaching out,

Please note that the developer portal is only for clarifying the integration steps,
You can’t integrate successfully using it because it has a dummy data.

The only ways to ensure successfully integration are on Simulation or Production Environments, our recommendation is to review the Educational library
carefully to ensure following all the steps.

Additionally, for OTP you can take it from fatoora portal for production or fatoora simulation portal for simulation based on the (certificateTemplateName = ASN1:PRINTABLESTRING:PREZATCA-Code-Signing) in your .cnf file, in your case (PREZATCA-Code-Signing) it’s for simulation which means you will get the OTP from fatoora simulation portal.

For any further concerns after reviewing the educational library shared on ZATCA site, please do not hesitate to reach out.

Thanks,
Ibrahem Daoud.

Try remove extension parameter.

openssl req -new -sha256 -key ec-secp256k1-priv-key.pem -config config.cnf -out my.csr