我在使用 RSACryptoServiceProvider.VerifyData 时遇到问题
NullReferenceException:对象引用未设置为对象 System.Security.Cryptography.RSACryptoServiceProvider.VerifyData(System.Byte[] 缓冲区,System.Object halg,System.Byte[] 签名)的实例(在 /Applications/buildAgent/work/ 3df08680c6f85295/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs:326)
您可以在 RSACryptoServiceProvider.cs 第 326 行看到异常我仔细检查了所有参数和 rsa 的创建——一切正常。有任何想法吗 ?
我的代码:
X509Certificate2 x509 = null;
RSACryptoServiceProvider rsa = null;
byte[] certificate = Convert.FromBase64String( certificate_s );
x509 = new X509Certificate2( certificate );
rsa = (RSACryptoServiceProvider) x509.PublicKey.Key;
bool sha1Valid = rsa.VerifyData( data, CryptoConfig.MapNameToOID("SHA1"), signature );