Skip to main content
All docs
V24.2

SignatureOptions Class

Contains signature options.

Namespace: DevExpress.Office.DigitalSignatures

Assembly: DevExpress.Docs.v24.2.dll

NuGet Package: DevExpress.Document.Processor

Declaration

public class SignatureOptions

Remarks

Pass the SignatureOptions object as the DocumentSigner.Sign method parameter to specify the signature parameters. The SignatureOptions.Certificate and SignatureOptions.DigestMethod properties are mandatory.

The code sample below specifies signature options and signs the file:

using DevExpress.Office.DigitalSignatures;
using DevExpress.Office.Tsp;
using System;
using System.Diagnostics;
using System.Security.Cryptography.X509Certificates;

static void SignDocument(string path, string output)
{
    DocumentSigner documentSigner = new DocumentSigner();
    documentSigner.Sign(path, output, CreateSignatureOptions(),
     new SignatureInfo());
    Process.Start(output);
}

static SignatureOptions CreateSignatureOptions()
{
  X509Certificate2 certificate = new X509Certificate2("Certificate/SignDemo.pfx", "dxdemo");
  Uri tsaServer = new Uri("https://freetsa.org/tsr");
  SignatureOptions options = new SignatureOptions();
  options.Certificate = certificate;
  if (tsaServer != null)
      options.TsaClient =
       new TsaClient(tsaServer, HashAlgorithmType.SHA256);

  options.SignatureFlags &= ~SignatureFlags.ValidateCertificate;
  options.CertificateKeyUsageFlags = X509KeyUsageFlags.None;
  options.DigestMethod = HashAlgorithmType.SHA256;

  X509ChainPolicy policy = new X509ChainPolicy();
  policy.RevocationMode = X509RevocationMode.NoCheck;
  policy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
  policy.VerificationFlags |= X509VerificationFlags.AllowUnknownCertificateAuthority |
      X509VerificationFlags.IgnoreCertificateAuthorityRevocationUnknown;
  options.CertificatePolicy = policy;
  options.TimestampCertificatePolicy = policy;

    return options;
}

Inheritance

Object
SignatureOptions
See Also