简体   繁体   English

.NET Core 2.0 RSA PlatformNotSupportedException

[英].NET Core 2.0 RSA PlatformNotSupportedException

I am trying to use this code to generate a public and private key, I am using .NET Core 2 on Windows 10 我正在尝试使用此代码生成公钥和私钥,我在Windows 10上使用.NET Core 2

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. 到目前为止,我没有成功运行此代码,它编译得很好,但是当我到达rsa.ToXmlString行时,它会丢弃PlatformNotSupportedException,当我在堆栈溢出的另一个答案中读到时,解决方案是使用System.Security.Cryptography.Algorithms和它们显示了我在下面使用的几乎精确的代码。

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

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

Error: 错误: 在此输入图像描述

As seen here it does show up in their API browser, so it has to be supported, right? 如此处所示它确实出现在他们的API浏览器中,因此必须得到支持,对吧? 在此输入图像描述

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,所以不建议使用.NET 4.6

.Net Core don't have the toXmlString() and fromXmlString method. .Net Core没有toXmlString()fromXmlString方法。 but you can use an extension 但你可以使用扩展名

Workarounds: #874 , #23686 解决方法: #874#23686

Update: 更新:

Added ToXmlString and FromXmlString implementations to RSA and DSA in .NET Core 3.0 在.NET Core 3.0 ToXmlStringFromXmlString实现添加到RSADSA

RSA & DSA examples. RSADSA示例。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM