posts - 303,  comments - 59,  views - 44万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

用的官方提供的demo,实际上部署后却出现了上图的错误。和技术支持沟通无效后,走上了不归路。

在微软的github dotnet/core开源库提交了issue后,终于获得了解决。附上链接:https://github.com/dotnet/core/issues/3020

 有道翻译一下:

CspParameters is about directly interacting with the Windows crypto libraries, which are only available on Windows.

If you're strongly typed as RSACryptoServiceProvider (which is generally a bad idea, it's the most limited of the RSA types) you can just eliminate the use of the CspParameters parameter... ImportParameters (when the key isn't named) makes a new ephemeral key and imports into that. And the original key size data is ignored when using ImportParameters.

CspParameters是关于直接与只在Windows上可用的Windows加密库交互的。 如果您是强类型为RSACryptoServiceProvider(这通常是一个坏主意,它是RSA类型中最受限制的),您可以直接取消使用CspParameters参数…ImportParameters(当键没有被命名时)创建一个新的临时键并导入其中。当使用ImportParameters时,原始密钥大小数据将被忽略。

附上官方demo代码,被注视掉的部分就是引起问题的原因:    

复制代码
 // ------- create RSACryptoServiceProvider instance and initialize with public key -----
                //CspParameters CspParameters = new CspParameters();
                //CspParameters.Flags = CspProviderFlags.UseMachineKeyStore;

                //int bitLen = 1024;
                //if ("RSA2".Equals(signType))
                //{
                //    bitLen = 2048;
                //}

                RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
                RSAParameters RSAparams = new RSAParameters();
                RSAparams.Modulus = MODULUS;
                RSAparams.Exponent = E;
                RSAparams.D = D;
                RSAparams.P = P;
                RSAparams.Q = Q;
                RSAparams.DP = DP;
                RSAparams.DQ = DQ;
                RSAparams.InverseQ = IQ;
                RSA.ImportParameters(RSAparams);
复制代码
posted on   芝麻的西瓜  阅读(902)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2017-07-12 asp.net core mvc 统一过滤参数,防止注入漏洞攻击
点击右上角即可分享
微信分享提示