日期:2014-05-17 浏览次数:21291 次
#region 验证签名
public Boolean Verify(byte[] sig, byte[] msg, string dn)
{
Boolean b = true;
try
{
ContentInfo signedData = new ContentInfo(msg);
SignedCms cms = new SignedCms(signedData, true);
cms.Decode(sig);
//Check Signature
cms.CheckSignature(true);
//Check dn
//if (cms.Certificates.Count > 0 )
//{
// X509Certificate2 cert = cms.Certificates[0];
// if (!string.IsNullOrEmpty(dn) && !dn.Equals(cert.Subject))
// {
// b = false;
// }
//}
byte[] data = cms.Encode();
}
catch (Exception e)
{
b = false;
}
return b;
}
#endregion