.NET Core 2.0 RSA PlatformNotSupportedException [英] .NET Core 2.0 RSA PlatformNotSupportedException

查看:29
本文介绍了.NET Core 2.0 RSA PlatformNotSupportedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此代码生成公钥和私钥,我在 Windows 10 上使用 .NET Core 2

I am trying to use this code to generate a public and private key, I am using .NET Core 2 on Windows 10

到目前为止,我没有成功运行此代码,它编译得很好,但是当我到达 rsa.ToXmlString 行时,它会出现 PlatformNotSupportedException 并且当我在另一个关于堆栈溢出的答案中阅读时,该解决方案正在使用 System.Security.Cryptography.Algorithms,他们展示了我在下面使用的几乎完全相同的代码.

So far I had no success in running this code, it compiles just fine but when I get to the rsa.ToXmlString line it drops with a PlatformNotSupportedException and as I read in another answer on stack overflow the solution was using System.Security.Cryptography.Algorithms and they showed the almost exact code that I use here down below.

        using (RSA rsa = RSA.Create())
        {
            rsa.KeySize = 1024;

            privateKey = rsa.ToXmlString(true);
            publicKey = rsa.ToXmlString(false);
        }

错误:

正如此处所见,它确实显示在他们的 API 浏览器中,因此必须支持它,对吗?

As seen here it does show up in their API browser, so it has to be supported, right?

有没有人遇到过类似的问题?或者有没有人解决这个问题?我必须使用 .NET Core 所以不建议使用 .NET 4.6

Does anyone have any similar problems? Or does anyone have a fix for this? I have to use .NET Core so don't suggest using .NET 4.6

推荐答案

看起来终于在 .NET Core 3.0 中实现了:https://github.com/dotnet/corefx/pull/37593

Looks like it's finally been implemented in .NET Core 3.0: https://github.com/dotnet/corefx/pull/37593

这篇关于.NET Core 2.0 RSA PlatformNotSupportedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆