Skip to main content
All docs
V24.2

SignatureValidationInfo Class

Contains signature validation information.

Namespace: DevExpress.Office.DigitalSignatures

Assembly: DevExpress.Docs.v24.2.dll

NuGet Package: DevExpress.Document.Processor

Declaration

public class SignatureValidationInfo

Remarks

Use the PackageSignatureValidation.Items property to obtain a list of SignatureValidationInfo objects. The number of items in the list is equal to the number of document signatures.

Use properties from the table below to get more specific information:

Property Description
SignatureValidationInfo.PassedChecks Returns verification types the signature passed.
SignatureValidationInfo.PassedCheckDetails Obtains information about passed verifications.
SignatureValidationInfo.FailedChecks Returns verification types the signature did not pass.
SignatureValidationInfo.FailedCheckDetails Retrieves information about failed verifications.
SignatureValidationInfo.CheckDetails Gets information about all verifications.

The code sample below validates signatures in a DOCX and XLSX document, checks the result, and displays information in the console:

using DevExpress.Office.DigitalSignatures;
using System.Diagnostics;
using System.Net;

static void Main(string[] args)
{
    ValidateSignature("Template_signed.docx");
    ValidateSignature("Template_signed.xlsx");
}

private static void ValidateSignature(string path)
{
    DocumentSigner validator = new DocumentSigner();

    //In this example, certificate validation is skipped
    SignatureValidationOptions validationOptions = new SignatureValidationOptions();
    validationOptions.ValidationFlags = ~ValidationFlags.ValidateSignatureCertificate & ~ValidationFlags.ValidateTimestampCertificate;

    //Validate the signature:
    PackageSignatureValidation signatureValidation = validator.Validate(path, validationOptions);
    AnalyzeValidationResult(signatureValidation);        

}

private static void AnalyzeValidationResult(PackageSignatureValidation signatureValidation)
{
    string validationMessage = signatureValidation.ResultMessage;

    //Check validation result and show information in the console:
    switch (signatureValidation.Result)
    {
        case PackageSignatureValidationResult.Valid:
            Console.WriteLine(validationMessage); Console.ReadKey();
            Process.Start(output);
            break;

        case PackageSignatureValidationResult.SignaturesNotFound:
            Console.WriteLine(validationMessage);
            break;

        case PackageSignatureValidationResult.Invalid:
        case PackageSignatureValidationResult.PartiallyValid:
            var failedCheckDetails = signatureValidation.Items[0].FailedCheckDetails;
            Console.WriteLine(validationMessage);
            int i = 1;
            foreach (SignatureCheckResult checkResult in failedCheckDetails)
            {
                Console.WriteLine(String.Format("Validation details {0}: \r\n" +
                    "{1} failed, Info: {2} \r\n", i, checkResult.CheckType, checkResult.Info));
                i++;
            }
            Console.ReadKey();
            break;
    }
}

Inheritance

Object
SignatureValidationInfo
See Also