我的组件负责从服务器下载文件。作为文件验证的一部分,我使用CAPICOM (SignedCode对象)来验证证书是否包含特定的字符串,并调用SignedCode对象的validation方法。如果文件包含名称中没有请求字符串的证书,系统会提示用户是否信任此文件。
由于微软将弃用CAPICOM,因此我需要使用.NET库来实现这些逻辑。如何使用.NET库获得相同的功能?网上有没有什么例子?
谢谢Zaky
发布于 2010-05-10 20:18:34
using System.Security.Cryptography;
// ....
byte[] SignData(byte[] toSign)
{
RSACryptoServiceProvider rsaCert =
GetCertificateWithPrivateKeyFromSomewhere(); // this method is yours
return rsaCert.SignData(toSign, new SHA1CryptoServiceProvider());
}
bool VerifyData(byte[] toVerify, byte[] signature)
{
RSACryptoServiceProvider rsaCert =
GetCertificateWithPublicKeyFromSomewhere(); // this method is yours
return rsaCert.VerifyData(toVerify, new SHA1CryptoServiceProvider(), signature);
}https://stackoverflow.com/questions/2802183
复制相似问题