Class PdfSignerCertificate
The PdfSignerCertificate class represents a signer's certificate used in PDF signing operations. It encapsulates information related to the signer's original certificate, as well as the associated OCSP (Online Certificate Status Protocol) and CRL (Certificate Revocation List) certificates.
Inheritance
System.Object
PdfSignerCertificate
Namespace: Syncfusion.Pdf.Security
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public class PdfSignerCertificate : Object
Constructors
PdfSignerCertificate()
Declaration
public PdfSignerCertificate()
Properties
Certificate
Gets the certificate associated with the signer.
Declaration
public X509Certificate2 Certificate { get; }
Property Value
Type |
---|
System.Security.Cryptography.X509Certificates.X509Certificate2 |
Examples
//Loads an existing document.
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Gets the signature field.
PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField;
//Validates signature and gets the validation result.
PdfSignatureValidationResult result = signatureField.ValidateSignature();
//Gets signer certificates
PdfSignerCertificate[] certifcate = result.SignerCertificates;
foreach (PdfSignerCertificate cert in certifcate)
{
//Get the actual signer certificate.
X509Certificate2 actualCertificate = cert.Certificate;
//Get the OCSP certificate.
PdfRevocationCertificate ocspCertificate = cert.OcspCertificate;
if (ocspCertificate != null)
{
//Gets a value indicating whether the revocation certificate is embedded within the PDF document
bool isOcspEmbedded = ocspCertificate.IsEmbedded;
//Gets the certificate associated with the revocation certificate
X509Certificate2 ocsPCert = ocspCertificate.Certificates[0];
//Gets the date and time when the revocation certificate becomes valid
DateTime currentUpdate = ocspCertificate.ValidFrom;
//Gets the date and time when the revocation certificate expires
DateTime nextUpdate = ocspCertificate.ValidTo;
}
//Get the CRL certificate.
PdfRevocationCertificate crlCertificate = cert.CrlCertificate;
if (crlCertificate != null)
{
//Gets a value indicating whether the revocation certificate is embedded within the PDF document
bool isCrlEmbedded = crlCertificate.IsEmbedded;
//Gets the certificate associated with the revocation certificate
X509Certificate2 crlCert = crlCertificate.Certificates[0];
//Gets the date and time when the revocation certificate becomes valid
DateTime currentUpdate = crlCertificate.ValidFrom;
//Gets the date and time when the revocation certificate expires
DateTime nextUpdate = crlCertificate.ValidTo;
}
}
//Close the document.
document.Close(true);
Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
Dim signatureField As PdfLoadedSignatureField = CType(document.Form.Fields(0),PdfLoadedSignatureField)
Dim result As PdfSignatureValidationResult = signatureField.ValidateSignature
Dim certifcate() As PdfSignerCertificate = result.SignerCertificates
For Each cert As PdfSignerCertificate In certifcate
'Get the actual signer certificate.
Dim actualCertificate As X509Certificate2 = cert.Certificate
'Get the OCSP certificate.
Dim ocspCertificate As PdfRevocationCertificate = cert.OcspCertificate
If (Not (ocspCertificate) Is Nothing) Then
'Gets a value indicating whether the revocation certificate is embedded within the PDF document
Dim isOcspEmbedded As Boolean = ocspCertificate.IsEmbedded
'Gets the certificate associated with the revocation certificate
Dim ocsPCert As X509Certificate2 = ocspCertificate.Certificates(0)
'Gets the date and time when the revocation certificate becomes valid
Dim currentUpdate As DateTime = ocspCertificate.ValidFrom
'Gets the date and time when the revocation certificate expires
Dim nextUpdate As DateTime = ocspCertificate.ValidTo
End If
'Get the CRL certificate.
Dim crlCertificate As PdfRevocationCertificate = cert.CrlCertificate
If (Not (crlCertificate) Is Nothing) Then
'Gets a value indicating whether the revocation certificate is embedded within the PDF document
Dim isCrlEmbedded As Boolean = crlCertificate.IsEmbedded
'Gets the certificate associated with the revocation certificate
Dim crlCert As X509Certificate2 = crlCertificate.Certificates(0)
'Gets the date and time when the revocation certificate becomes valid
Dim currentUpdate As DateTime = crlCertificate.ValidFrom
'Gets the date and time when the revocation certificate expires
Dim nextUpdate As DateTime = crlCertificate.ValidTo
End If
Next
'Close the document.
document.Close(true)
CrlCertificate
Gets the CRL (Certificate Revocation List) certificate associated with the signer's certificate.
Declaration
public PdfRevocationCertificate CrlCertificate { get; }
Property Value
Type |
---|
PdfRevocationCertificate |
Examples
//Loads an existing document.
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Gets the signature field.
PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField;
//Validates signature and gets the validation result.
PdfSignatureValidationResult result = signatureField.ValidateSignature();
//Gets signer certificates
PdfSignerCertificate[] certifcate = result.SignerCertificates;
foreach (PdfSignerCertificate cert in certifcate)
{
//Get the actual signer certificate.
X509Certificate2 actualCertificate = cert.Certificate;
//Get the OCSP certificate.
PdfRevocationCertificate ocspCertificate = cert.OcspCertificate;
if (ocspCertificate != null)
{
//Gets a value indicating whether the revocation certificate is embedded within the PDF document
bool isOcspEmbedded = ocspCertificate.IsEmbedded;
//Gets the certificate associated with the revocation certificate
X509Certificate2 ocsPCert = ocspCertificate.Certificates[0];
//Gets the date and time when the revocation certificate becomes valid
DateTime currentUpdate = ocspCertificate.ValidFrom;
//Gets the date and time when the revocation certificate expires
DateTime nextUpdate = ocspCertificate.ValidTo;
}
//Get the CRL certificate.
PdfRevocationCertificate crlCertificate = cert.CrlCertificate;
if (crlCertificate != null)
{
//Gets a value indicating whether the revocation certificate is embedded within the PDF document
bool isCrlEmbedded = crlCertificate.IsEmbedded;
//Gets the certificate associated with the revocation certificate
X509Certificate2 crlCert = crlCertificate.Certificates[0];
//Gets the date and time when the revocation certificate becomes valid
DateTime currentUpdate = crlCertificate.ValidFrom;
//Gets the date and time when the revocation certificate expires
DateTime nextUpdate = crlCertificate.ValidTo;
}
}
//Close the document.
document.Close(true);
Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
Dim signatureField As PdfLoadedSignatureField = CType(document.Form.Fields(0),PdfLoadedSignatureField)
Dim result As PdfSignatureValidationResult = signatureField.ValidateSignature
Dim certifcate() As PdfSignerCertificate = result.SignerCertificates
For Each cert As PdfSignerCertificate In certifcate
'Get the actual signer certificate.
Dim actualCertificate As X509Certificate2 = cert.Certificate
'Get the OCSP certificate.
Dim ocspCertificate As PdfRevocationCertificate = cert.OcspCertificate
If (Not (ocspCertificate) Is Nothing) Then
'Gets a value indicating whether the revocation certificate is embedded within the PDF document
Dim isOcspEmbedded As Boolean = ocspCertificate.IsEmbedded
'Gets the certificate associated with the revocation certificate
Dim ocsPCert As X509Certificate2 = ocspCertificate.Certificates(0)
'Gets the date and time when the revocation certificate becomes valid
Dim currentUpdate As DateTime = ocspCertificate.ValidFrom
'Gets the date and time when the revocation certificate expires
Dim nextUpdate As DateTime = ocspCertificate.ValidTo
End If
'Get the CRL certificate.
Dim crlCertificate As PdfRevocationCertificate = cert.CrlCertificate
If (Not (crlCertificate) Is Nothing) Then
'Gets a value indicating whether the revocation certificate is embedded within the PDF document
Dim isCrlEmbedded As Boolean = crlCertificate.IsEmbedded
'Gets the certificate associated with the revocation certificate
Dim crlCert As X509Certificate2 = crlCertificate.Certificates(0)
'Gets the date and time when the revocation certificate becomes valid
Dim currentUpdate As DateTime = crlCertificate.ValidFrom
'Gets the date and time when the revocation certificate expires
Dim nextUpdate As DateTime = crlCertificate.ValidTo
End If
Next
'Close the document.
document.Close(true)
OcspCertificate
Gets the OCSP (Online Certificate Status Protocol) certificate associated with the signer's certificate.
Declaration
public PdfRevocationCertificate OcspCertificate { get; }
Property Value
Type |
---|
PdfRevocationCertificate |
Examples
//Loads an existing document.
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Gets the signature field.
PdfLoadedSignatureField signatureField = document.Form.Fields[0] as PdfLoadedSignatureField;
//Validates signature and gets the validation result.
PdfSignatureValidationResult result = signatureField.ValidateSignature();
//Gets signer certificates
PdfSignerCertificate[] certifcate = result.SignerCertificates;
foreach (PdfSignerCertificate cert in certifcate)
{
//Get the actual signer certificate.
X509Certificate2 actualCertificate = cert.Certificate;
//Get the OCSP certificate.
PdfRevocationCertificate ocspCertificate = cert.OcspCertificate;
if (ocspCertificate != null)
{
//Gets a value indicating whether the revocation certificate is embedded within the PDF document
bool isOcspEmbedded = ocspCertificate.IsEmbedded;
//Gets the certificate associated with the revocation certificate
X509Certificate2 ocsPCert = ocspCertificate.Certificates[0];
//Gets the date and time when the revocation certificate becomes valid
DateTime currentUpdate = ocspCertificate.ValidFrom;
//Gets the date and time when the revocation certificate expires
DateTime nextUpdate = ocspCertificate.ValidTo;
}
//Get the CRL certificate.
PdfRevocationCertificate crlCertificate = cert.CrlCertificate;
if (crlCertificate != null)
{
//Gets a value indicating whether the revocation certificate is embedded within the PDF document
bool isCrlEmbedded = crlCertificate.IsEmbedded;
//Gets the certificate associated with the revocation certificate
X509Certificate2 crlCert = crlCertificate.Certificates[0];
//Gets the date and time when the revocation certificate becomes valid
DateTime currentUpdate = crlCertificate.ValidFrom;
//Gets the date and time when the revocation certificate expires
DateTime nextUpdate = crlCertificate.ValidTo;
}
}
//Close the document.
document.Close(true);
Dim document As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
Dim signatureField As PdfLoadedSignatureField = CType(document.Form.Fields(0),PdfLoadedSignatureField)
Dim result As PdfSignatureValidationResult = signatureField.ValidateSignature
Dim certifcate() As PdfSignerCertificate = result.SignerCertificates
For Each cert As PdfSignerCertificate In certifcate
'Get the actual signer certificate.
Dim actualCertificate As X509Certificate2 = cert.Certificate
'Get the OCSP certificate.
Dim ocspCertificate As PdfRevocationCertificate = cert.OcspCertificate
If (Not (ocspCertificate) Is Nothing) Then
'Gets a value indicating whether the revocation certificate is embedded within the PDF document
Dim isOcspEmbedded As Boolean = ocspCertificate.IsEmbedded
'Gets the certificate associated with the revocation certificate
Dim ocsPCert As X509Certificate2 = ocspCertificate.Certificates(0)
'Gets the date and time when the revocation certificate becomes valid
Dim currentUpdate As DateTime = ocspCertificate.ValidFrom
'Gets the date and time when the revocation certificate expires
Dim nextUpdate As DateTime = ocspCertificate.ValidTo
End If
'Get the CRL certificate.
Dim crlCertificate As PdfRevocationCertificate = cert.CrlCertificate
If (Not (crlCertificate) Is Nothing) Then
'Gets a value indicating whether the revocation certificate is embedded within the PDF document
Dim isCrlEmbedded As Boolean = crlCertificate.IsEmbedded
'Gets the certificate associated with the revocation certificate
Dim crlCert As X509Certificate2 = crlCertificate.Certificates(0)
'Gets the date and time when the revocation certificate becomes valid
Dim currentUpdate As DateTime = crlCertificate.ValidFrom
'Gets the date and time when the revocation certificate expires
Dim nextUpdate As DateTime = crlCertificate.ValidTo
End If
Next
'Close the document.
document.Close(true)