Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated CSR is not accepted by Compliance API #47

Closed
faizytech-devsy opened this issue Dec 17, 2024 · 2 comments
Closed

Generated CSR is not accepted by Compliance API #47

faizytech-devsy opened this issue Dec 17, 2024 · 2 comments

Comments

@faizytech-devsy
Copy link

`$data = CSRRequest::make()
->setUID($params['organization_identifier'])
->setSerialNumber('POS Name', 'G4', '18c46ddc-f8b6-4047-bab5-e3993471fd98')
->setCommonName($params['common_name'])
->setCountryName($params['country'])
->setOrganizationName($params['organization_name'])
->setOrganizationalUnitName($params['organization_unit_name'])
->setRegisteredAddress($params['location'])
->setInvoiceType(true, true) //invoice types , the default is true, true
->setCurrentZatcaEnv(CSRRequest::SANDBOX) //support all modes ['sandbox','simulation','core']
->setBusinessCategory($params['industry']);

    $CSR = GenerateCSR::fromRequest($data)->initialize()->generate();

    // writing the private_key to file
    openssl_pkey_export_to_file($CSR->getPrivateKey(), $storageDir.'/zatca_key.pem');`
    
    I have generate CSR from this code but the compliance API is not accepting it.
    
   CURL request below
    `curl --location 'https://gw-fatoora.zatca.gov.sa/e-invoicing/developer-portal/compliance' \

--header 'Accept-Version: V2'
--header 'OTP: 123345'
--header 'Accept: application/json'
--header 'Content-Type: application/json'
--header 'Cookie: TS0106293e=0132a679c0786d22f5f3e29fbd2531cc0b8621318f36543d54ee886ca0a95a7f1736364eab655e2f6f987560358d2a2e5e74b3b4df'
--data '{
"csr": "MIIBBDCBrAIBADBNMQswCQYDVQQGEwJTQTEWMBQGA1UECwwNSmVkZGFoIEJyYW5jaDESMBAGA1UECgwJTXlDb21wYW55MRIwEAYDVQQDDAkxMjcuMC4wLjEwVjAQBgcqhkjOPQIBBgUrgQQACgNCAAQhByhJZ4MQsAPLjbSKTzZ9YNLUpPomdCFxrzVHxh3RmgAn5ndpUXvzDRwQFAMO0XLn0kQ7ZRjrjITRH6iDuyNuoAAwCgYIKoZIzj0EAwIDRwAwRAIgLLjoBYCmSeowe0x7ByDzmNUIwKDu25JCUqOeseRvcgYCIG/pIvidpdSDKy24naoSnfRsMOIWu6/YE041EU3YQcuC"
}'`

The output show Invalid Request with status 400.

Kindly guide me what i am doing wrong
Thanks in advance.

@nomi-techie
Copy link

@faizytech-devsy
converts Certificate Signing Request (CSR) into a Base64 encoded string than send to zatca.

@faizytech-devsy
Copy link
Author

@nomi-techie thanks for your help. I also discovered it just yesterday myself. I am amaze that this is not written anywhere in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants