officefileapi-devexpress-dot-pdf-dot-pdfdocumentsigner-dot-getpdfpkcs7signature-x28-system-dot-string-x29.md
Retrieves the PKCS#7 signature of the signature field.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Docs.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public PdfPkcs7Signature GetPdfPkcs7Signature(
string signatureFieldName
)
Public Function GetPdfPkcs7Signature(
signatureFieldName As String
) As PdfPkcs7Signature
| Name | Type | Description |
|---|---|---|
| signatureFieldName | String |
The signed form field.
|
| Type | Description |
|---|---|
| PdfPkcs7Signature |
A PdfPkcs7Signature object that contains information about the PKCS#7 signature.
|
Call the GetPdfPkcs7Signature method to obtain information about the PKCS#7 signature of the specified signature field.
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();
}
Imports DevExpress.Pdf
' ...
Using documentSigner As New PdfDocumentSigner(stream)
For Each signature In documentSigner.GetSignatureInfo()
' Obtain the PKCS#7 signature.
Dim pkcs7 = documentSigner.GetPdfPkcs7Signature(signature.FieldName)
' Obtain the PKCS#7 signature certificate.
Dim certificate = pkcs7.GetSignatureCertificate()
' Check wheter the signature is valid.
Dim isValid As Boolean = pkcs7.VerifySignature()
' Verify the signature certificate info.
Dim issuerName As String = certificate.IssuerName.Name
Dim isCertificateValid As Boolean = certificate.Verify()
' Verify the time of signing.
Dim timeStamp = pkcs7.GetTimeStampDate()
Dim isTimeStampValid As Boolean = pkcs7.VerifyTimeStamp()
Next signature
End Using
See Also