zoukankan      html  css  js  c++  java
  • dotnet core linux 接入支付宝H5支付,提示:System.PlatformNotSupportedException","Message":"'CspParameters' requires Windows Cryptographic API (CAPI), which is not available on this platform.

    用的官方提供的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);
  • 相关阅读:
    浅析影响一个网站的因素
    23种常用设计模式的UML类图
    各版本IE兼容问题,IE6,IE7,IE8,IE9,IE10,IE11
    47种常见的浏览器兼容性问题大汇总
    5个Sublime Text 的插件推荐
    网页设计师神器,快速生成网站配色、字型等风格的工具——Stylify Me
    免费的高分辨率图库——re:splashed 可用做网页背景、设计或桌面壁纸
    MySQL(18):Select- subquery子查询
    MySQL(17):Select-union(联合查询)使用注意事项
    MySQL(16):Select-union(联合查询)
  • 原文地址:https://www.cnblogs.com/zinan/p/11174731.html
Copyright © 2011-2022 走看看