Sign Document Net Function Errors

Hi engineers,

I’m using ZATCA .net SDK in my .net app

I face some errors in this signing function
IEInvoiceSigner invoiceSigner= new EInvoiceSigner();
SignResult signResult= invoiceSigner.SignDocument(xmlDoc, csrResult.Csr, csrResult.PrivateKey)

The main error is:
“[Error] Parsing EInvoice Certificate[Error] Populating Signed Signature Properties[Error] Generating EInvoice QR Code”

and when I check for the steps errors it come like these:

Step[3] Parse Certificate - Exception: “Cannot find the requested object”
Step[6] Populate Signed Signature Properties - Exception: “Object reference not set to an instance of an object”
Step[9] Generate EInvoice QR - Exception: “Invalid Certificate”;

Is that I missed some files like pem file ?
If yes then which one of it (I have two pem files) and how to make it readable for SignDocument() function ?

Thank you for help

Dear @khaledmaqtari

Thank you for reaching out, and welcome to our community.

Kindly make sure that the Private Key is the same as generating the CSR, for the Signing process refer back to the below document.

SigningProcessUpdated.pdf (392.7 KB)

Follow the XML tags & UBL In slide 3, For the Singing Properties tags kindly follow the attached document on slide 6, 7 and make sure of using the correct tags.

If you still face issues, please don’t hesitate to reach out with our support team via email:

SP email: sp_support@zatca.gov.sa

Thanks,

1 Like

Thank you very much for fast help.

About the xml tags I just testing a ready simplified and standard invoice files that included in ZATCA SDK data directory.

I’ll check again with that pdf guides and then reporting you the result.

did you solve it?
passing csrResult.Csr, csrResult.PrivateKey as is? or change something?

Dear @khaledmaqtari

Actually I didn’t use Zatca SDK in my Project, I just tried it and it worked. Maybe you can get an Idea how to use SDK in your project from the following image.

1 Like

Thank you Mr @eCloud for your support.

Currently that problem solved but now I countered with I new problem
It is about why B2B cleared but B2C only reported in sandbox invoice compliance.
But failed in sandbox single reporting and simulation compliance.
It’s error is: "Invalid signed properties hashing, SignedProperties with id='xadesSignedProperties'"
If you have any idea check my post here , please.

Thank you Can you give me a cleaninvoice.xml format before I sign?

[Error] Parsing EInvoice Certificate[Error] Populating Signed Signature Properties[Error] Generating EInvoice QR Code

khaledmaqtari Could you help me with the solution? I would be grateful to you

[Error] Parsing EInvoice Certificate[Error] Populating Signed Signature Properties[Error] Generating EInvoice QR Code

Hello @alroaini2030
Actually that old error was because the structure of my own xml invoice.
So, I used the example xml invoices that come with zatca SDK

If you haven’t yet download it may you download it form here
Then you will find the example files in the path ends with: \Data\Samples

For doing your signing you can use that SDK Fatoora CLI command (Java) or .Net libraries -Readme files inside the folder \Readme will help you how to do it.
Or you can use your won code by following SigningProcessUpdated.pdf

can you please share the project it not working for me

For Signing Invoice, you just need copy Data folder from SDK to your Project Folder. And add Project Reference from \zatca-einvoicing-sdk-238-R3.3.4\Lib\Dot-Net8\DLL\Zatca.EInvoice.SDK\net8.0

From my picture above it shows me Invoice Signed Successfully. but signed Invoice Generated with that code does not PASS Validation.

I have finished with all the process here without SDK .

I want to try using .Net SDK because SDK has a feature for Invoice validation, but I also failed to use it.

So I’m also waiting for someone to share some working code using the .NET SDK.

when i add Project Reference from \zatca-einvoicing-sdk-238-R3.3.4\Lib\Dot-Net8\DLL\Zatca.EInvoice.SDK\net8.0

not working this is the error msg
(Severity Code Description Project File Line Suppression State Details
Error (active) CS1705 Assembly ‘Zatca.EInvoice.SDK’ with identity ‘Zatca.EInvoice.SDK, Version=3.3.4.0, Culture=neutral, PublicKeyToken=cf541c52f43eaadd’ uses ‘System.Xml.ReaderWriter, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ which has a higher version than referenced assembly ‘System.Xml.ReaderWriter’ with identity ‘System.Xml.ReaderWriter, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ ConsoleApp2 D:\الملفات\سطح المكتب\ConsoleApp2\ConsoleApp2\CSC 1
)

Make sure you add the SDK Library according to the Project Target Framework you created. Look in this folder zatca-einvoicing-sdk-238-R3.3.4\Lib\Dot-Net8\DLL\Zatca.EInvoice.SDK

Net Core 3.1, NetFramework 4.8 or .Net 8

i copy zatca dll from 48 folder and it work but there is problem in signing its valid and not pass with cmd
fatooraNet sign -invoice c:\test\bassam.xml -signedInvoice c:\test\bas.xml


the file pass
with dll not pass