# Get Errors when generate B2C invoices

**URL:** <https://zatca1.discourse.group/t/get-errors-when-generate-b2c-invoices/695>\
**Category:** Signing process\
**Created:** [September 6, 2023, 12:39pm UTC](https://zatca1.discourse.group/t/get-errors-when-generate-b2c-invoices/695 "2023-09-06T12:39:49Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![ad.almusbahi](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@ad.almusbahi](https://zatca1.discourse.group/u/ad.almusbahi)\
**Post date:** [November 27, 2023, 8:18pm UTC](https://zatca1.discourse.group/t/get-errors-when-generate-b2c-invoices/695/10 "2023-11-27T20:18:33Z")

</div>

Yes, sure.  
there are two ways to do it.

1. Use the OpenSSL command to convert the private key format “openssl ecparam -name secp256k1 -genkey -noout -out private-key.pem”.  
2-C# code to convert the private key to PEM format:

```auto
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;

class Program{
	static void Main(string[] args){
		string privateKeyContent = "XXXXXXXXXXXXXX";// the private key contant genetated by ZATKA SDK
		AsymmetricKeyParameter privateKey = PrivateKeyFactory.CreateKey(Convert.FromBase64String(privateKeyContent));
		privateKeyContent = ConvertPrivateKeyToPem(privateKey);
		Console.WriteLine(privateKeyContent);
	}

	public static string ConvertPrivateKeyToPem(AsymmetricKeyParameter privateKey)
	{
		StringWriter stringWriter = new StringWriter();
		PemWriter pemWriter = new PemWriter(stringWriter);
		pemWriter.WriteObject(privateKey);
		pemWriter.Writer.Flush();
		return stringWriter.ToString();
	}
}

```

Regards

---

_[View the full topic](https://zatca1.discourse.group/t/get-errors-when-generate-b2c-invoices/695)._
