Verify Digital signatures in the document

Overview

GroupDocs.Signature providesΒ DigitalVerifyOptionsΒ classΒ to specify different options for digital signatures verification.

Note
Verification performs two independent checks. First the signature itself is verified cryptographically: if the document was altered after signing, the result is not valid regardless of any other option. Then any criteria you set on DigitalVerifyOptions - certificate, subject name, issuer name, signing time, reason, contact or location - are matched. Both must pass for IsValid to be true. For PDF documents the cryptographic check was added in GroupDocs.Signature for .NET 26.9; earlier versions compared only the criteria.

Here are the steps to verify Digital signature within the document with GroupDocs.Signature:

This example shows how to verify Digital signature in the document.

using (Signature signature = new Signature("sample.pdf"))
{
    DigitalVerifyOptions options = new DigitalVerifyOptions("certificate.pfx")
    {
        Password = "1234567890",
        // the subject of the signing certificate must contain this text
        SubjectName = "John Smith",
        // the signing reason stored in the PDF signature must be equal to this text
        Reason = "Approved"
    };
    // verify document signatures
    VerificationResult result = signature.Verify(options);
    if (result.IsValid)
    {
        Console.WriteLine("\nDocument was verified successfully!");
    }
    else
    {
        Console.WriteLine("\nDocument failed verification process.");
    }
}

Verification criteria by document format

Not every property of DigitalVerifyOptions applies to every document format. A property that does not apply is ignored, so it can neither reject nor accept a signature. For example, Comments has no effect on a PDF document, because PDF signatures have no comment field: use Reason instead.

PropertyPDFWord ProcessingSpreadsheetPresentation
Certificate (serial number and thumbprint)yesyesyesyes
SubjectName, IssuerNameyesyesnono
SignDateTimeFrom, SignDateTimeToyesyesyesyes
Reason, Contact, Locationyesnonono
Commentsnoyesyesyes

SubjectName and IssuerName match when the subject or issuer of the signing certificate contains the value, case-sensitive. They apply to PDF documents starting with GroupDocs.Signature for .NET 26.9; earlier versions ignored them there.

Advanced Usage Topics

To learn more about document eSign features, please refer to theΒ advanced usage section.

More resources

GitHub Examples

You may easily run the code above and see the feature in action in ourΒ GitHub examples:

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.