C# 第326行出现RSACryptServiceProvider.VerifyData异常

C# 第326行出现RSACryptServiceProvider.VerifyData异常,c#,nullreferenceexception,rsacryptoserviceprovider,C#,Nullreferenceexception,Rsacryptoserviceprovider,我在使用RSACryptoServiceProvider.VerifyData时遇到问题 NullReferenceException:对象引用未设置为 对象 System.Security.Cryptography.RSACryptServiceProvider.VerifyData (System.Byte[]缓冲区,System.Object halg,System.Byte[]签名) (在 /Applications/buildAgent/work/3df08680c6f85295/mc

我在使用RSACryptoServiceProvider.VerifyData时遇到问题

NullReferenceException:对象引用未设置为 对象 System.Security.Cryptography.RSACryptServiceProvider.VerifyData (System.Byte[]缓冲区,System.Object halg,System.Byte[]签名) (在 /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Security.Cryptography/rsacyptoserviceprovider.cs:326)

您可以在RSACryptServiceProvider.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 );
解决了。 由halg参数--CryptoConfig.MapNameToOID(“SHA1”)引起的错误 似乎在Unity C#脚本中是非法的
必须改为使用HashAlgorithm.Create(“SHA1”)

哪一行是326?什么是
证书
数据
签名
?Unity标签用于Microsoft Unity。请不要误用它。