We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

IsDocumentModified on ValidateSignature is not working?

Thread ID:

Created:

Updated:

Platform:

Replies:

148570 Oct 25,2019 07:08 AM UTC Dec 19,2019 12:29 PM UTC ASP.NET Core - EJ 2 11
loading
Tags: PDF
Jeffrey
Asked On October 25, 2019 07:10 AM UTC

Hello,

When changing a signed PDF and validate this changed PDF document we get result that document is not modified while when we open the changed PDF in adobe reader we get the message that the PDF was modified after signing. Are we doing something wrong or is the IsDocumentModified property not working correctly?

We are using version 17.3.0.19 of Syncfusion.Pdf.Net.Core

Sample source code:
            //Create PDF
            using (PdfDocument document = new PdfDocument())
            {
                //Load certificate
                PdfCertificate pdfCert = null;
                using (FileStream certificateStream1 = new FileStream(@".pfx", FileMode.Open, FileAccess.Read))
                {
                    pdfCert = new PdfCertificate(certificateStream1, "");
                }

                //Add a page and text to the document.
                PdfPage page = document.Pages.Add();
                page.Graphics.DrawString("Hello World!!!", new PdfStandardFont(PdfFontFamily.Helvetica, 20), PdfBrushes.Black, new Syncfusion.Drawing.PointF(0, 0));

                //Add a digital signature.
                PdfSignature signature = new PdfSignature(document, page, pdfCert, "Signature");

                //Save to file system
                using (Stream tempPdfNameStream = new FileStream("file1.pdf", FileMode.Create))
                {
                    document.Save(tempPdfNameStream);
                }
                document.Close();
            }

            //Change PDF
            using (FileStream fileStream = new FileStream("file1.pdf", FileMode.Open))
            using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
            {
                loadedDocument.Pages[0].Graphics.DrawString("Change PDF!!!", new PdfStandardFont(PdfFontFamily.Helvetica, 30), PdfBrushes.Black, new Syncfusion.Drawing.PointF(100, 100));

                //Save doc to file system
                using (FileStream fileStream2 = new FileStream("fileChanged.pdf", FileMode.Create))
                {
                    loadedDocument.Save(fileStream2);
                }

                loadedDocument.Close();
            }

            //Validate
            using (FileStream fileStream = new FileStream("fileChanged.pdf", FileMode.Open))
            using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
            {
                var signatureField = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;
                var res = signatureField.ValidateSignature();
                if (!res.IsDocumentModified) throw new Exception("The value of IsDocumentModified when validating the PDF document should be true and not false!");
            }

            Console.WriteLine("Everyting works like expected");
            Console.ReadLine();
        }

Gowthamraj Kumar [Syncfusion]
Replied On October 28, 2019 08:23 AM UTC

Hi Jeffrey, 

Thank you for using Syncfusion products. 

Currently we are trying to reproduce the reported issue in our end and we will update the further details on October 30th 2019. 

Regards, 
Gowthamraj K 


Sowmiya Loganathan [Syncfusion]
Replied On October 30, 2019 02:12 PM UTC

Hi Jeffrey,  

Sorry for the delay. Currently we are validating the issue which you have mentioned and we will update the further details by 1st November, 2019. 

Regards, 
Sowmiya Loganathan 


Sowmiya Loganathan [Syncfusion]
Replied On November 1, 2019 06:42 AM UTC

Hi Jeffrey, 

We can able to reproduce the reported issue “Signature validation is not proper for modified PDF documents”. We conformed it as a defect and patch for this issue fix will be available on 6th November 2019. 
 
Regards, 
Sowmiya Loganathan 


Sowmiya Loganathan [Syncfusion]
Replied On November 6, 2019 04:47 PM UTC

Hi Jeffrey, 

Sorry for the inconvenience caused. 

Due to complexities to handling incremental updated archive objects, still we are working on this with high priority. We will provide the patch on 13th November 2019. 
 
Regards, 
Sowmiya Loganathan 


Sowmiya Loganathan [Syncfusion]
Replied On November 13, 2019 12:24 PM UTC

Hi Jeffery,  

We have fixed the issue with “Signature validation is not proper for modified PDF documents” and the fix is included in our latest weekly NuGet package which is available in the following link.  

Kindly try this in your side and let us know if you need any further assistance. 
 
Regards, 
Sowmiya Loganathan 


Jeffrey
Replied On November 24, 2019 08:22 PM UTC

Hello,

The sample application is working now with the latest weekly build but the following sample is not working:
            //Create PDF
            using (PdfDocument document = new PdfDocument())
            {
                //Add a page and text to the document.
                PdfPage page = document.Pages.Add();
                page.Graphics.DrawString("Hello World!!!", new PdfStandardFont(PdfFontFamily.Helvetica, 20), PdfBrushes.Black, new Syncfusion.Drawing.PointF(0, 0));

                //Save to file system
                using (Stream tempPdfNameStream = new FileStream("file1.pdf", FileMode.Create))
                {
                    document.Save(tempPdfNameStream);
                }
                document.Close();
            }

            //Add signature to file
            using (FileStream fileStream = new FileStream("file1.pdf", FileMode.Open))
            using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
            {
                //Load certificate
                PdfCertificate pdfCert = null;
                using (FileStream certificateStream1 = new FileStream(@".pfx", FileMode.Open, FileAccess.Read))
                {
                    pdfCert = new PdfCertificate(certificateStream1, "");
                }

                //Add a digital signature.
                PdfSignature signature = new PdfSignature(loadedDocument, loadedDocument.Pages[0], pdfCert, "Signature");

                //Save doc to file system
                using (FileStream fileStream2 = new FileStream("file2.pdf", FileMode.Create))
                {
                    loadedDocument.Save(fileStream2);
                }

                loadedDocument.Close();
            }


            //Change PDF after signature
            using (FileStream fileStream = new FileStream("file2.pdf", FileMode.Open))
            using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
            {
                loadedDocument.Pages[0].Graphics.DrawString("Change PDF!!!", new PdfStandardFont(PdfFontFamily.Helvetica, 30), PdfBrushes.Black, new Syncfusion.Drawing.PointF(100, 100));

                //Save doc to file system
                using (FileStream fileStream2 = new FileStream("fileChanged.pdf", FileMode.Create))
                {
                    loadedDocument.Save(fileStream2);
                }

                loadedDocument.Close();
            }

            //Validate
            using (FileStream fileStream = new FileStream("fileChanged.pdf", FileMode.Open))
            using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
            {
                var signatureField = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;
                var res = signatureField.ValidateSignature();
                if (!res.IsDocumentModified) throw new Exception("The value of IsDocumentModified when validating the PDF document should be true and not false!");
            }

            Console.WriteLine("Everyting works like expected");
            Console.ReadLine();

Regards,
Jeffrey

Sowmiya Loganathan [Syncfusion]
Replied On November 25, 2019 09:01 AM UTC

Hi Jeffrey, 

We were able to reproduce the mentioned issue and suspect that this to a defect. Currently we are validating the same and will update the further details by 27th November, 2019.  

Regards, 
Sowmiya Loganathan 


Sowmiya Loganathan [Syncfusion]
Replied On November 28, 2019 12:29 PM UTC

Hi Jeffery, 

Thank you for your patience.  

Thanks for your patience. We have confirmed that the reported issue with “IsDocumentModified on ValidateSignature is not working” is defect. And we are working on this with high priority. The patch for this issue fix will be available on or before 04th December 2019. 
 
Regards, 
Sowmiya Loganathan 


Sowmiya Loganathan [Syncfusion]
Replied On December 4, 2019 09:30 AM UTC

Hi Jeffery, 
 
We have fixed the reported issue and the fix will included in our upcoming weekly NuGet package release which is available on 10th December 2019. 
 
Regards, 
Sowmiya Loganathan 


Sowmiya Loganathan [Syncfusion]
Replied On December 10, 2019 10:58 AM UTC

Hi Jeffrey, 
 
We have include the code changes for the reported issue “IsDocumentModified on ValidateSignature is not working” in weekly NuGet release. Please find the download link from below, 
 
Regards, 
Sowmiya Loganathan  


Sowmiya Loganathan [Syncfusion]
Replied On December 19, 2019 12:29 PM UTC

Hi Jeffery, 
 
We have included the “Validating digital signature based on the incremental updates in our Essential Studio 2019 Volume 4 Release v17.4.0.39. We are glad to announce that it is rolled out and is available for download under the following link. 
 
Please find the documentation link from below, 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Sowmiya Loganathan        


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon