bassemAgmi / EInvoicingSigner

A command prompt application used to serialize and sign tax payers documents before sending the documents to Egyptian Tax Authority.
68 stars 56 forks source link

Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException #16

Open AvaSharkawy opened 2 years ago

AvaSharkawy commented 2 years ago

Hello, I have an exception in SignWithCMS Method

Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Provider could not perform the action since the context was acquired as silent.

any one knows how to solve this?

bassemAgmi commented 2 years ago

If you are using ASP.NET, impersonate the current user for your ASP.NET application.

AvaSharkawy commented 2 years ago

I'm using .NET Core WinForms, is there any kind of permissions? I've tried to run application as administrator and the same exception occurs

AvaSharkawy commented 2 years ago

I've tried your run-time console version and the same exception occurs. Is there is something I'm missing?

bassemAgmi commented 2 years ago

if you change the line cms.ComputeSignature(signer) to be cms.ComputeSignature(signer,false), it will ask you for a PIN. This means the current user is not authorized to access the token certificate.

norhan22 commented 1 year ago

@bassemAgmi

I face same problem I plugged the ePass2003 token and login via the EnterSafe PKI Manager successfully and Installed the certificate on local machine into the Trusted Root Certification Authorities folder via the installer

what should I do else to authorize the user and sign the doc JSON successfully ?

and also have questions

Zed56 commented 1 year ago

same problem any updates?

socertis commented 1 year ago

one of the solutions is to prompt the user with a list of certificates available on his system to choose from. I already have implemented it on top of this source code, and it is available here.