- Create and Verify Digital Signatures using .NET Digital Signature Library
- .NET Digital Signature Library Code Samples
- Download .NET Digital Signature Library with all samples
void VerifyCadesSignature()
{
CadesVerify cv = new CadesVerify("signedDocument.docx.p7s", "");
Console.WriteLine("Number of signatures: " + cv.Signatures.Count.ToString());
//verify every digital signature from the signed document
foreach (CadesSignatureInfo csi in cv.Signatures)
{
Console.WriteLine("Hash Algorithm: " + csi.HashAlgorithm.FriendlyName);
Console.WriteLine("Signature Certificate Information");
Console.WriteLine("Certificate issued by:" + csi.SignatureCertificate.Issuer);
Console.WriteLine("Certificate will expire on: " + csi.SignatureCertificate.NotAfter.ToString());
Console.WriteLine("Certificate is valid: "
+ DigitalCertificate.VerifyDigitalCertificate(csi.SignatureCertificate, VerificationType.CRL));
Console.WriteLine("Signature Is Valid: " + csi.SignatureIsValid.ToString());
Console.WriteLine("Signature Time: " + csi.SignatureTime.ToLocalTime().ToString());
Console.WriteLine("Is Timestamped: " + csi.SignatureIsTimestamped);
if (csi.SignatureIsTimestamped == true)
{
Console.WriteLine("Hash Algorithm: " + csi.TimestampInfo.HashAlgorithm.FriendlyName);
Console.WriteLine("Is TimestampAltered: " + csi.TimestampInfo.IsTimestampAltered.ToString());
Console.WriteLine("TimestampSerial Number: " + csi.TimestampInfo.SerialNumber);
Console.WriteLine("TSA Certificate: " + csi.TimestampInfo.TsaCertificate.Subject);
}
}
}
See also: