Slip
Slip

Reputation: 603

System.Security.Cryptography.Csp on Ubuntu 16.04

I have ASP.Net Core 1.0.0 app using cryptography. I need to decrypt keys using RSACryptoServiceProvider. Visual Studio suggested adding System.Security.Cryptography.Csp version 4.0.0 to my dependencies. I accept, and on Windows it all works just fine. But when I deployed it on Ubuntu 16.04 RSACryptoServiceProvider's methods started to throw PlatformNotSupportedException exception. Am I using the wrong assembly? I found https://github.com/dotnet/corefx/tree/v1.0.0/src/System.Security.Cryptography.Csp and there is 1.0.0 version. Is that what I need? How can I add it to my project?

Upvotes: 3

Views: 1964

Answers (1)

Kévin Chalet
Kévin Chalet

Reputation: 42110

RSACryptoServiceProvider is based on CryptoAPI, a Windows-specific unmanaged API. Since it's not available on Linux, a PlatformNotSupportedException exception is thrown at runtime.

Instead, consider referencing System.Security.Cryptography.Algorithms and using RSA.Create() to get an implementation compatible with your environment (on Linux, you'll get a RSAOpenSsl instance).

Upvotes: 6

Related Questions