-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
RSACng Decryption throwing Internal Error Occurred exception #97027
Comments
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones Issue DetailsI'm working with Safenet Token JC and I'm trying to deploy a service that interacts with it using .NET 8 and minimal API, this is the exact method i'm using to run the decryption process byte[]? DecryptData(X509Certificate2? cert, byte[] data)
}
|
When using keys from something other than the builtin software key provider you're at the mercy of whatever error codes the provider-writer felt like offering. Psychic debugging suggests either a) your service user doesn't have permission to the private key, or b) when running as a service the provider can't figure out a way to PIN prompt. Try running as the same user account, but in a UI/interactive context; if that works, it's (b). If that fails, try as a different user (which might reveal (a)). |
Actually, I'm using Microsoft X509Certificate2 store to lookup the certificate in question than since I'm using .NET8, I had to use RSACng to read the private key, my dilemma is when I run the debug everything works when I run release (I used the administrator account in order to avoid the permissions issues), I've tried windows 10 and 11 same story, if Am at the mercy of the vendor why it works on debug and not on release. |
CNG is a Windows feature that is based on Providers. Windows itself comes with a few providers, however Providers can be provided by 3rd parties, and frequently so, when the need arises for a Provider to bridge between a piece of hardware like a token and CNG. Providers are free to do whatever they need to bridge this interface between CNG and the Hardware. Some themselves have something like a sub-Provider, like SmartCards have MiniDrivers. All that is to say, CNG is doing a lot of things under the covers any there are many failure points. One place for us to start is to figure out what Provider your certificate and key are actually using. You should be able to do something like this: RSACng rsa = GetYourKey();
string provider = rsa.Key.Provider.Provider; If you log the value of
As Jeremy alluded to, this is much more likely to be an issue with the token or CNG Provider. I don't know that sharing the code would help, but if you have a small program that reproduces the issue, it would not hurt to provide one. |
This issue has been marked |
the provider is eToken Base Cryptographic Provider. |
@bartonjs Do you suspect this is an issue with the provider itself? @aminemarckader I know a lot of time has passed on this issue; did you find a way past it already? |
Either an issue with the provider, or with its permissions model, or something. And I definitely can't explain why it would change between debug and release (unless they are being launched from the IDE and have different launch profiles) |
Good evening everyone, thanks a lot for your efforts.
Actually, the permissions.inf file has been modified with every permission
possible. I made the service interactive, I've logged in with administrator
account and for the profiles, that route I didn't pursue because I didn't
touch any profile what so ever.
I can provide the code if it helps.
The real problem is with decrypt method encryption works perfectly but the
decryption throws the issue
…On Mon, Nov 11, 2024, 7:39 PM Jeremy Barton ***@***.***> wrote:
Either an issue with the provider, or with its permissions model, or
something. And I definitely can't explain why it would change between debug
and release (unless they are being launched from the IDE and have different
launch profiles)
—
Reply to this email directly, view it on GitHub
<#97027 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHXTMMBUK4UCT5UAHM52NTL2AD2XDAVCNFSM6AAAAABRPTGHXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRYHAYTAMZQGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'm working with Safenet Token JC and I'm trying to deploy a service that interacts with it using .NET 8 and minimal API,
the encryption and decryption processes are being executed using asymmetric keys from a certificates stored in Safenet token and retreived as X509Certificate2 Object;
so far I go it to encrypt a string while debugging and decryption is fine but when I deploy the release exe as a service I always get this error
this is the exact method i'm using to run the decryption process
The text was updated successfully, but these errors were encountered: