Back to Devexpress

PdfDocumentSigner.AddToDss(String, IList<Byte[]>, IList<Byte[]>, IList<Byte[]>) Method

officefileapi-devexpress-dot-pdf-dot-pdfdocumentsigner-dot-addtodss-x28-string-ilist-byte-ilist-byte-ilist-byte-x29.md

latest4.6 KB
Original Source

PdfDocumentSigner.AddToDss(String, IList<Byte[]>, IList<Byte[]>, IList<Byte[]>) Method

Adds information about the specified signature to the Document Security Store (DSS).

Namespace : DevExpress.Pdf

Assembly : DevExpress.Docs.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public void AddToDss(
    string signatureFieldName,
    IList<byte[]> certificates,
    IList<byte[]> crls,
    IList<byte[]> ocsp
)
vb
Public Sub AddToDss(
    signatureFieldName As String,
    certificates As IList(Of Byte()),
    crls As IList(Of Byte()),
    ocsp As IList(Of Byte())
)

Parameters

NameTypeDescription
signatureFieldNameString

The name of the form field that contains the target signature.

| | certificates | IList<Byte[]> |

A list of certificates used to create the certificate chain.

| | crls | IList<Byte[]> |

A list of DER-encoded CertificateList ASN.1 objects (rfc5280) that contain the Certificate Revocation List (CRL) for every certificate in the chain (except the root certificate).

| | ocsp | IList<Byte[]> |

A list of DER-encoded OCSPResponse ASN.1 objects (rfc6960) that contain the OCSP server response for every certificate in the chain except root.

|

Exceptions

TypeDescription
ArgumentException

Occurs if the specified form field is not signed.

|

Remarks

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

See Also

PdfDocumentSigner Class

PdfDocumentSigner Members

DevExpress.Pdf Namespace