背景:
最近在做一个支付对接,使用到Sha1WithRsa对发送数据进行签名,和对回复数据进行验签的工作。
使用p12私钥进行发送数据的签名,使用cer公钥证书对回复数据进行签名信息的验签
测试的时候使用的是.Net Framework进行,读取出来的Key对象是System.Security.Cryptography.RSACryptoServiceProvider

而正是环境是在netcore中进行编码,读出来的Key对象是System.Security.Cryptography.RSACng

所使用的验签函数也会不同,在程序中使用如下方法,供参考:
//验证签名,如果密钥为RSACng形式,则使用RSACng的函数进行验证;
//如果密钥为RSACryptoServiceProvider,则使用RSACryptoServiceProvider的函数进行验证。

另外,在发布到IIS环境时候,报如下错:
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: 系统找不到指定的文件。
参考:https://www.cnblogs.com/wjx-blog/p/11127638.html 的解决,在此谢谢jiancaixing

写此记录供参考
浙公网安备 33010602011771号