Skip to main content
All docs
V25.1
  • PdfSignatureBase.GetSignatureCertificate() Method

    Gets the signature certificate.

    Namespace: DevExpress.Pdf

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

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public X509Certificate2 GetSignatureCertificate()

    Returns

    Type Description
    X509Certificate2

    The X.509 certificate.

    Remarks

    The code snippet below obtains the PKCS#7 signature from a PDF document saved to the stream. Once the signature is obtained, the code checks attributes such as the time of signing, the signer’s identity, and authenticity of the signature.

    using DevExpress.Pdf;
    // ...
    using(PdfDocumentSigner documentSigner = new PdfDocumentSigner(stream))
        // Obtain the PKCS#7 signature from the list of `PdfSignatureInfo` objects.
        foreach(var signature in documentSigner.GetSignatureInfo()) {
            var pkcs7 = documentSigner.GetPdfPkcs7Signature(signature.FieldName);
           // Obtain the PKCS#7 signature certificate.
            var certificate = pkcs7.GetSignatureCertificate();
           // Check wheter the signature is valid.
            bool isValid = pkcs7.VerifySignature();
            // Verify the signature certificate info.
            string issuerName = certificate.IssuerName.Name;
            bool isCertificateValid = certificate.Verify();
            // Verify the time of signing.
            var timeStamp = pkcs7.GetTimeStampDate();
            bool isTimeStampValid = pkcs7.VerifyTimeStamp();
        }
    
    See Also