# CSR and Private key generation

**URL:** <https://zatca1.discourse.group/t/csr-and-private-key-generation/874>\
**Category:** SDK, web-based validator and sandbox\
**Created:** [October 22, 2023, 9:37pm UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874 "2023-10-22T21:37:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohamedmtaha30](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@mohamedmtaha30](https://zatca1.discourse.group/u/mohamedmtaha30)\
**Post date:** [October 22, 2023, 9:37pm UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/1 "2023-10-22T21:37:35Z")

</div>

Dears,

I have two questions

1- When I try to generate csr from sdk cli using this command

```auto
fatoora -sim -csr -csrConfig config.properties -privateKey privateKey.pem -generatedCsr csr.pem  

```

it will generate the private key with the name I provided but the csr will be generated with the default name

2- To sign the invoices in sdk I should put the path of the certificate in config.json  
How can I get my certificate to put it in the sdk to start signing the invoices

---

<div class="post-metadata">

**Author:** ![kiaziz](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kiaziz](https://zatca1.discourse.group/u/kiaziz)\
**Post date:** [October 25, 2023, 6:28am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/2 "2023-10-25T06:28:09Z")

</div>

1. for the first command please use it like this:  
**fatoora -sim -csr -csrConfig config.properties**  
also the CSR and private key are not generated with the extension “.pem”  
it’s only the certificate which can be found in SDK/Data/Certificates folder.

2. the certificate used to sign the invoices is the one returned from Production CSID API.  
you will get token decode that and put the decoded string in the cert.pem file found in SDK/Data/Certificates and you are ready to sign your invoices.  
using command **Fatoora -sign -invoice [_invoice.xml_]**

Regards,

---

<div class="post-metadata">

**Author:** ![mohamedmtaha30](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@mohamedmtaha30](https://zatca1.discourse.group/u/mohamedmtaha30)\
**Post date:** [October 26, 2023, 10:56am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/3 "2023-10-26T10:56:40Z")

</div>

Thanks for your reply

regarding the first point what should I do to generate csr and private key files with custom names like csr and privateKey  
in the documentation it says but -privateKey -generatedCsr   
if i use them together it will only name the private key (first in order) and will generate the csr with the default name

---

<div class="post-metadata">

**Author:** ![kiaziz](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kiaziz](https://zatca1.discourse.group/u/kiaziz)\
**Post date:** [October 26, 2023, 11:20am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/4 "2023-10-26T11:20:58Z")

</div>

yes it will be generated with the default name. then you can rename it with whatever you want.

Regards,

---

<div class="post-metadata">

**Author:** ![itujar\_it](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@itujar\_it](https://zatca1.discourse.group/u/itujar_it)\
**Post date:** [September 7, 2024, 8:55am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/5 "2024-09-07T08:55:58Z")

</div>

But there will be more private key if we using as cloud .right ?  
so what will be the solution?  
how can we find the private key if we dont know the exact name.

while I generate the CSR from sdk with below command  
fatoora -sim -csr -csrConfig MER123\_csr-config.properties -generatedCsr MER123\_csr.csr -privatekey MER123\_private.key  
the private key is generated some random number not as we expected.

@kiaziz do you find any solutions?

---

<div class="post-metadata">

**Author:** ![emyr](https://avatars.discourse-cdn.com/v4/letter/e/58956e/32.png) [@emyr](https://zatca1.discourse.group/u/emyr)\
**Post date:** [September 18, 2024, 9:56am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/6 "2024-09-18T09:56:49Z")

</div>

@itujar_it @kiaziz

have you found a solution to this for cloud case?

---

<div class="post-metadata">

**Author:** ![itujar\_it](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@itujar\_it](https://zatca1.discourse.group/u/itujar_it)\
**Post date:** [September 19, 2024, 11:13am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/7 "2024-09-19T11:13:07Z")

</div>

We are now using Java libraries instead of using fatoora command to generate CSR, CSID, and privateKey.

---

<div class="post-metadata">

**Author:** ![kalaiarasan](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kalaiarasan](https://zatca1.discourse.group/u/kalaiarasan)\
**Post date:** [November 8, 2024, 6:11am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/8 "2024-11-08T06:11:21Z")

</div>

![Screenshot (42)](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/original/1X/b871a4ff1effc7f32b24be37825ab5e983f13bed.png)

i use this comment **fatoora -sim -csr -csrConfig config.properties**  
where is csr …? and key …?

---

<div class="post-metadata">

**Author:** ![eCloud](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ecloud/32/629_2.png) [@eCloud](https://zatca1.discourse.group/u/eCloud)\
**Post date:** [November 8, 2024, 8:48am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/9 "2024-11-08T08:48:29Z")

</div>

> [@kalaiarasan](#):
>
> i use this comment **fatoora -sim -csr -csrConfig config.properties**  
> where is csr …? and key …?

Should be in the directory where you ran the command

 ![{232D7ED2-81EE-40F9-A778-3B234D856690}](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/original/1X/83ed1fdd5f33208b269ad104be9809fdb5c71320.png)

---

<div class="post-metadata">

**Author:** ![kalaiarasan](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kalaiarasan](https://zatca1.discourse.group/u/kalaiarasan)\
**Post date:** [November 8, 2024, 9:13am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/10 "2024-11-08T09:13:02Z")

</div>

![Screenshot (46)](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/original/1X/313d6825ccebc6ebc4402a3676c6d1e829706dd0.png)

what is Erorr…?

---

<div class="post-metadata">

**Author:** ![eCloud](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ecloud/32/629_2.png) [@eCloud](https://zatca1.discourse.group/u/eCloud)\
**Post date:** [November 8, 2024, 9:27am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/11 "2024-11-08T09:27:41Z")

</div>

Just read the response, you will see what is [ERROR]

![image](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/optimized/1X/51f11d7399101a6049096553148f9c0f5f79feae_2_690x58.png)

---

<div class="post-metadata">

**Author:** ![kalaiarasan](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kalaiarasan](https://zatca1.discourse.group/u/kalaiarasan)\
**Post date:** [November 8, 2024, 9:28am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/12 "2024-11-08T09:28:42Z")

</div>

Csr configuration file not found…this correct…?

---

<div class="post-metadata">

**Author:** ![kalaiarasan](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kalaiarasan](https://zatca1.discourse.group/u/kalaiarasan)\
**Post date:** [November 8, 2024, 9:32am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/13 "2024-11-08T09:32:37Z")

</div>

thank you bro it’s create Csr

---

<div class="post-metadata">

**Author:** ![kalaiarasan](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kalaiarasan](https://zatca1.discourse.group/u/kalaiarasan)\
**Post date:** [November 8, 2024, 9:38am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/14 "2024-11-08T09:38:18Z")

</div>

bro same step for Signing and Generating Invoice Hash…?

---

<div class="post-metadata">

**Author:** ![eCloud](https://dub1.discourse-cdn.com/flex013/user_avatar/zatca1.discourse.group/ecloud/32/629_2.png) [@eCloud](https://zatca1.discourse.group/u/eCloud)\
**Post date:** [November 8, 2024, 9:38am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/15 "2024-11-08T09:38:19Z")

</div>

Actually you can specify the file name and where the csr and private key will be created.

Like this

```auto
PS C:\tmp> fatoora generateCsr -csr -nonprod -csrConfig "C:\zatca-einvoicing-sdk-238-R3.3.6\Data\Input\csr-config-example-EN.properties" -privateKey "c:\tmp\cert\PrivateKey.pem" -generatedCsr "c:\tmp\cert\taxpayer.csr"

```

---

<div class="post-metadata">

**Author:** ![kalaiarasan](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@kalaiarasan](https://zatca1.discourse.group/u/kalaiarasan)\
**Post date:** [November 9, 2024, 6:26am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/16 "2024-11-09T06:26:13Z")

</div>

how do create qr code …?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/zatca1/original/1X/ecc8b6c09fb5a3d5f1f7a7ecc6a3e02b5adb889e.png)

---

<div class="post-metadata">

**Author:** ![Saud](https://avatars.discourse-cdn.com/v4/letter/s/c68b51/32.png) [@Saud](https://zatca1.discourse.group/u/Saud)\
**Post date:** [December 17, 2024, 8:42am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/17 "2024-12-17T08:42:27Z")

</div>

@itujar_it Which Java library are you using?

I am facing issue in my cloud application when detailing with multiple onboarding.

---

<div class="post-metadata">

**Author:** ![host1k](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@host1k](https://zatca1.discourse.group/u/host1k)\
**Post date:** [March 12, 2025, 10:48am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/18 "2025-03-12T10:48:47Z")

</div>

MacOs  
ZatcaSDK  
`fatoora -csr -sim -csrConfig csr-config-2.properties`  
created 2 files with pk/csr with names which generated by sdk

`fatoora -csr -sim -csrConfig csr-config-2.properties -generatedCsr keys/csr-2`  
created PK with name, generated by sdk  
created CSR in keys/csr-2

`fatoora -csr -sim -csrConfig csr-config-2.properties -privateKey keys/pk-2`  
created CSR with name, generated by sdk  
created PK in keys/pk-2

Here all fine. But I can’t use it together

`fatoora -csr -sim -csrConfig csr-config-2.properties -generatedCsr keys/csr-2 -privateKey keys/pk-2`  
generated PK in a way like I didn’t specified it, but CSR where i specified it

In case if I swap them in place:  
`fatoora -csr -sim -csrConfig csr-config-2.properties -privateKey keys/pk-2 -generatedCsr keys/csr-2`  
generated CSR in a way like I didn’t specified it, but PK where i specified it

So last one is actually getting ignored

How can I handle it ?

---

<div class="post-metadata">

**Author:** ![KHALID\_SHOKRY](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@KHALID\_SHOKRY](https://zatca1.discourse.group/u/KHALID_SHOKRY)\
**Post date:** [April 30, 2025, 5:36pm UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/19 "2025-04-30T17:36:54Z")

</div>

I have the same problem . . . PLZ can you guide me hot to solve it

---

<div class="post-metadata">

**Author:** ![Aturkistani](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@Aturkistani](https://zatca1.discourse.group/u/Aturkistani)\
**Post date:** [May 1, 2025, 7:52am UTC](https://zatca1.discourse.group/t/csr-and-private-key-generation/874/20 "2025-05-01T07:52:49Z")

</div>

Dear @KHALID_SHOKRY,

please create a new ticket (topic) with providing the required & supporting details.

Regards,

[Next page](https://zatca1.discourse.group/t/csr-and-private-key-generation/874.md?page=2)
