【问题标题】:System.Security.Cryptography.Csp on Ubuntu 16.04Ubuntu 16.04 上的 System.Security.Cryptography.Csp
【发布时间】:2016-08-22 12:37:00
【问题描述】:

我有使用密码学的 ASP.Net Core 1.0.0 应用程序。我需要使用RSACryptoServiceProvider 解密密钥。 Visual Studio 建议将 System.Security.Cryptography.Csp 版本 4.0.0 添加到我的依赖项中。我接受,在 Windows 上一切正常。但是当我在 Ubuntu 16.04 RSACryptoServiceProvider 上部署它时,方法开始抛出 PlatformNotSupportedException 异常。我使用了错误的程序集吗? 我找到了https://github.com/dotnet/corefx/tree/v1.0.0/src/System.Security.Cryptography.Csp 并且有 1.0.0 版本。那是我需要的吗?如何将其添加到我的项目中?

【问题讨论】:

    标签: c# asp.net-core cryptoapi ubuntu-16.04


    【解决方案1】:

    RSACryptoServiceProvider 基于 CryptoAPI,一种 Windows 特定的非托管 API。由于它在 Linux 上不可用,因此在运行时会引发 PlatformNotSupportedException 异常。

    相反,请考虑引用System.Security.Cryptography.Algorithms 并使用RSA.Create() 来获得与您的环境兼容的实现(在Linux 上,您将获得RSAOpenSsl 实例)。

    【讨论】:

    • 谢谢! RSA 工作正常。但我仍然不明白在 Net Standart 包中包含特定于 Windows 的工具...
    • 并非每个人都需要或希望在 .NET Core 中获得跨平台支持。使用特定于实现的包允许直接使用RSACryptoServiceProviderRSACngRSAOpenSsl,这可以实现高级场景(例如,您可以使用CngKey,它在使用RSACng 时依赖于特定的密钥存储提供程序)
    猜你喜欢
    • 2016-11-26
    • 1970-01-01
    • 2016-11-17
    • 2018-02-02
    • 2016-11-08
    • 2020-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多