Back to Devexpress

CertificateStoreProvider Class

officefileapi-devexpress-dot-office-dot-digitalsignatures-959f0e54.md

latest3.7 KB
Original Source

CertificateStoreProvider Class

Provides certificates used to build a certificate chain and register the signature in the Document Security Store (DSS).

Namespace : DevExpress.Office.DigitalSignatures

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public class CertificateStoreProvider :
    ICertificateStoreProvider,
    IDisposable
vb
Public Class CertificateStoreProvider
    Implements ICertificateStoreProvider,
               IDisposable

Remarks

The CertificateStoreProvider class is the default ICertificateStoreProvider implementation.

Use this class object as the PdfDocumentSigner.AddToDss method parameter to provide certificates used to build a certificate chain and add the signature to the DSS.

The code sample below retrieves the name of the first signature field, adds the related signature’s information to the DSS, and applies a timestamp to the document.

csharp
using (var signer = new PdfDocumentSigner(@"signed.pdf"))
{
    ITsaClient tsaClient = new TsaClient(new Uri(@"https://freetsa.org/tsr"), HashAlgorithmType.SHA256);

    string signatureName = signer.GetSignatureFieldNames(false)[0];

   // Create a provider that retrieves certificates from a store:
    using (var certificateStoreProvider =
        new CertificateStoreProvider(new X509Store(StoreLocation.CurrentUser), true))
    {
        // Add the signature to the security store
        // and specify the CrlClient and OcspClient objects
        // used to check the certificates' revocation status:
        signer.AddToDss(signatureName, new CrlClient(), new OcspClient(), certificateStoreProvider);
    }
    signer.SaveDocument(@"signedLTV.pdf", new[] { new PdfSignatureBuilder(new PdfTimeStamp(tsaClient)) });
}
vb
Using signer = New PdfDocumentSigner("signed.pdf")
  Dim tsaClient As ITsaClient = New TsaClient(New Uri("https://freetsa.org/tsr"), HashAlgorithmType.SHA256)

  Dim signatureName As String = signer.GetSignatureFieldNames(False)(0)

  ' Create a provider that retrieves certificates from a store:
  Using certificateStoreProvider = 
      New CertificateStoreProvider(New X509Store(StoreLocation.CurrentUser), True)
    ' Add the signature to the security store
    ' and specify the CrlClient and OcspClient objects
    ' used to check the certificates' revocation status:
    signer.AddToDss(signatureName, New CrlClient(), New OcspClient(), certificateStoreProvider)
  End Using
  signer.SaveDocument("signedLTV.pdf", { New PdfSignatureBuilder(New PdfTimeStamp(tsaClient)) })
End Using

Implements

ICertificateStoreProvider

IDisposable

Inheritance

Object CertificateStoreProvider

See Also

CertificateStoreProvider Members

DevExpress.Office.DigitalSignatures Namespace