officefileapi-devexpress-dot-pdf-8bc6a57a.md
Contains settings used to verify signature revocation status online.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public struct PdfRevocationVerificationOptions
Public Structure PdfRevocationVerificationOptions
The following code snippet checks the status of signature certificates in the “Signed_file.pdf” file:
using DevExpress.Pdf;
namespace ConsoleApp {
internal class Program {
static void Main(string[] args) {
CheckCertificateRevocationInfo();
}
public static void CheckCertificateRevocationInfo() {
using (PdfDocumentSigner documentSigner = new PdfDocumentSigner("Signed_file.pdf"))
// Retrieve the list of `PdfSignatureInfo` objects in the document.
foreach (var signature in documentSigner.GetSignatureInfo()){
Console.WriteLine("Signature field name : {0}", signature.FieldName);
Console.WriteLine("Signer name : {0}", signature.SignerName);
var pkcs7 = documentSigner.GetPdfPkcs7Signature(signature.FieldName);
Console.WriteLine("Is signature valid? : {0}", pkcs7.VerifySignature());
// Check wheter CRL/OCSP responses are embedded in the signature. If not, request them online.
Console.WriteLine("Is CRL embedded?: {0}", pkcs7.CrlList != null);
Console.WriteLine("Is OCSP embedded?: {0}", pkcs7.OcspList != null);
PdfRevocationVerificationOptions options = new PdfRevocationVerificationOptions(){
TryFetchCrlOnline = pkcs7.CrlList == null,
TryFetchOcspOnline = pkcs7.OcspList == null,
};
// Obtain information about signature certificate revocation.
var result = pkcs7.CheckCertificateRevocation(DateTime.UtcNow, options);
Console.WriteLine("Is certificate revoked?: {0}", result.IsCrlRevoked);
if (result.IsCrlRevoked)
Console.WriteLine("Is CRL found online?: {0}", result.IsCrlFoundOnline);
Console.WriteLine("OCSP Response Status: {0}", result.OcspRevocationStatus);
if (result.OcspRevocationStatus != PdfOcspRevocationStatus.None)
Console.WriteLine("Is OCSP found online?: {0}", result.IsOcspFoundOnline);
// Check whether the signature is a TimeStamp.
Console.WriteLine("Is Document Timestamp?: {0}", pkcs7.IsDocumentTimeStamp);
Console.WriteLine();
}
}
}
}
Imports DevExpress.Pdf
Namespace ConsoleApp
Friend Class Program
Shared Sub Main(ByVal args() As String)
CheckCertificateRevocationInfo()
End Sub
Public Shared Sub CheckCertificateRevocationInfo()
Using documentSigner As New PdfDocumentSigner("Signed_file.pdf")
' Retrieve the list of `PdfSignatureInfo` objects in the document.
For Each signature In documentSigner.GetSignatureInfo()
Console.WriteLine("Signature field name : {0}", signature.FieldName)
Console.WriteLine("Signer name : {0}", signature.SignerName)
Dim pkcs7 = documentSigner.GetPdfPkcs7Signature(signature.FieldName)
Console.WriteLine("Is signature valid? : {0}", pkcs7.VerifySignature())
' Check whether CRL/OCSP responses are embedded in the signature. If not, request them online.
Console.WriteLine("Is CRL embedded?: {0}", pkcs7.CrlList IsNot Nothing)
Console.WriteLine("Is OCSP embedded?: {0}", pkcs7.OcspList IsNot Nothing)
Dim options As New PdfRevocationVerificationOptions() With {
.TryFetchCrlOnline = pkcs7.CrlList Is Nothing,
.TryFetchOcspOnline = pkcs7.OcspList Is Nothing
}
' Obtain information about signature certificate revocation.
Dim result = pkcs7.CheckCertificateRevocation(Date.UtcNow, options)
Console.WriteLine("Is certificate revoked?: {0}", result.IsCrlRevoked)
If result.IsCrlRevoked Then
Console.WriteLine("Is CRL found online?: {0}", result.IsCrlFoundOnline)
End If
Console.WriteLine("OCSP Response Status: {0}", result.OcspRevocationStatus)
If result.OcspRevocationStatus <> PdfOcspRevocationStatus.None Then
Console.WriteLine("Is OCSP found online?: {0}", result.IsOcspFoundOnline)
End If
' Check whether the signature is a TimeStamp.
Console.WriteLine("Is Document Timestamp?: {0}", pkcs7.IsDocumentTimeStamp)
Console.WriteLine()
Next signature
End Using
End Sub
End Class
End Namespace
The result is shown below:
Signature field name : Signature1
Signer name : DevExpress Demo
Is signature valid? : True
Is CRL embedded?: False
Is OCSP embedded?: False
Is certificate revoked?: False
OCSP Response Status: Good
Is OCSP found online: True
Is Document Timestamp: False
Signature field name : Signature1
Signer name : DevExpress Demo
Is signature valid? : True
Is CRL embedded?: False
Is OCSP embedded?: False
Is certificate revoked?: False
OCSP Response Status: Unknown
Is OCSP found online: True
Is Document Timestamp: True
See Also