.NET Core 2.0 RSA PlatformNotSupportedException [英] .NET Core 2.0 RSA PlatformNotSupportedException
问题描述
我正在尝试使用此代码生成公共密钥和私有密钥,我正在Windows 10上使用.NET Core 2
到目前为止,我在运行此代码,它可以很好地进行编译,但是当我到达rsa.ToXmlString行时,它会落在PlatformNotSupportedException上,当我在堆栈溢出中读取另一个答案时,解决方案是使用 System.Security.Cryptography.Algorithms
,他们在下面显示了我在此处使用的几乎准确的代码。
使用(RSA rsa = RSA.Create())
{
rsa.KeySize = 1024;
privateKey = rsa.ToXmlString(true);
publicKey = rsa.ToXmlString(false);
}
错误:
有人有任何类似的问题吗?还是有人对此有解决方法?
我必须使用.NET Core,所以建议不要使用.NET 4.6
看起来终于有了在.NET Core 3.0中实施: https://github.com/dotnet/corefx/pull/37593
I am trying to use this code to generate a public and private key, I am using .NET Core 2 on Windows 10
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);
}
Error:
As seen here it does show up in their API browser, so it has to be supported, right?
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
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屋!