- Home
- Forum
- ASP.NET MVC
- How to verify PDF signature
How to verify PDF signature
I need to verify if PDF document is signed (by Sincfusion library or other application) and is it modified after initially digitaly signed.
Is it possible with Syncfusion library?
SIGN IN To post a reply.
4 Replies
SL
Sowmiya Loganathan
Syncfusion Team
May 9, 2018 10:59 AM UTC
Hi Lajos,
Thank you for contacting Syncfusion support.
At present we do not have support to validate digital signature in an existing PDF document. We have already logged a feature request and added it to our feature request list. We do not have any immediate plans to implement this feature. We will let you know once the feature is implemented.
Please find our support list in the below link:
Please let us know if you have any further assistance on this.
Regards,
Sowmiya L
LD
Lajos Djerfi
May 11, 2018 10:18 AM UTC
All right,
I understand that I can not do integrity checking with your library. Can I enumerate all signatures from file and get all fields from signatures and from certificates.
Best regards.
SL
Sowmiya Loganathan
Syncfusion Team
May 14, 2018 12:03 PM UTC
Hi Lajos,
We can get all the signature fields and its signature properties from the existing PDF document, but it is not possible to get the certificates from the PDF document. Please refer the below code snippet for your reference,
|
//Loads a PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Gets the form fields collection
PdfLoadedFormFieldCollection fields = loadedDocument.Form.Fields;
//Gets the first signature field of the PDF document
PdfLoadedSignatureField field = fields[0] as PdfLoadedSignatureField;
//Gets the signature from the signature field
PdfSignature sigature = field.Signature; |
Please let us know if you need any further assistance on this.
Regards,
Sowmiya L
SL
Sowmiya Loganathan
Syncfusion Team
October 3, 2019 07:07 AM UTC
Hi Lajos,
We glad to announce that the feature “Support for validating digital signatures in existing PDF document” is implemented and it is included in our Essential Studio 2019 Volume 3 Beta release v17.3.0.9. This is rolled out and is available for download under the following link,
Please find the code snippet to illustrate this from below,
|
//Load an existing signed PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Get signature field
PdfLoadedSignatureField signatureField = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;
//X509Certificate2Collection to check the signer's identity using root certificates
X509CertificateCollection collection = new X509CertificateCollection();
//Create new X509Certificate2 with the root certificate
X509Certificate2 certificate = new X509Certificate2("PDF.pfx", "syncfusion");
//Add the certificate to the collection
collection.Add(certificate);
//Validate signature and get the validation result
PdfSignatureValidationResult result = signatureField.ValidateSignature(collection);
//Checks whether the signature is valid or not
SignatureStatus status = result.SignatureStatus;
//Checks whether the document is modified or not
bool isModified = result.IsDocumentModified;
//Signature details
string issuerName = signatureField.Signature.Certificate.IssuerName;
DateTime validFrom = signatureField.Signature.Certificate.ValidFrom;
DateTime validTo = signatureField.Signature.Certificate.ValidTo;
string signatureAlgorithm = result.SignatureAlgorithm;
DigestAlgorithm digestAlgorithm = result.DigestAlgorithm;
//Revocation validation details
RevocationResult revocationDetails = result.RevocationResult;
RevocationStatus revocationStatus = revocationDetails.OcspRevocationStatus;
bool isRevokedCRL = revocationDetails.IsRevokedCRL;
//Checks whether the signature is valid or not based on the overall validation
bool isSignatureValid = result.IsSignatureValid;
//Close the document
loadedDocument.Close(true); |
Regards,
Sowmiya Loganathan
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
-
LD Lajos Djerfi
- May 8, 2018 01:25 PM UTC
- Oct 3, 2019 07:07 AM UTC