Aspose.Pdf signing issue

Hi,


I’m using Aspose.Pdf.Facades.PdfFileSignature to digitally sign PDFs.

If I sign a document in the UK time zone and then open it shortly afterwards with Adobe Reader in the US Eastern time zone, the digital signature is shown as invalid with the message ‘Signature seems to be signed in future’.

Initially this appeared to be a problem with Adobe Reader, but if I alter my code to use Aspose.Pdf.Kit.PdfFileSignature, the signature is shown as valid.

I have prepared the attached PDF documents, one signed with PDF Kit and one signed with Facades. When I open them in Adobe Reader, I see the following when I right-click on the signature and choose ‘Show signature properties’:

Aspose.Pdf.Facades.PdfFileSignature:
Signing time UK time zone: 2013/05/07 09:16:06 +01’00’ Signature is VALID
Signing time US Eastern time zone: 2013/05/07 09:16:06 -04’00’ Signature is INVALID: Signature seems to be signed in future

Aspose.Pdf.Kit.PdfFileSignature:
Signing time UK time zone:2013/05/07 09:13:33 +01’00’ Signature is VALID
Signing time US Eastern time zone: 2013/05/07 04:13:33 -04’00’ Signature is VALID

With the US Eastern time zone, the time displayed is the same as the UK time zone for the Facades-generated signature, but 5 hours earlier with the Pdf.Kit-generated signature (which is correct). This means that the problem must lie with Aspose.Pdf.Facades.PdfFileSignature.

Also, I note that when signing with PDF Kit, a blue bar is visible within Adobe Reader indicating that the document is ‘Signed and all signatures are valid.’ How can I get this to be displayed with Facades.PdfFileSignature?

Finally, I found this page in the Aspose.Pdf.Facades documentation…

Securing and signing PDF in C#|Aspose.PDF for .NET

…but Apose.Pdf.Facades.PdfFileSignature does not have the CertificationLevel property.

Sample code for Aspose.Pdf.Facades:

private Stream AddDigitalSignature(Stream pdf, string signatureFile, string signaturePassword)
{
// Create the signer.
Aspose.Pdf.Facades.PdfFileSignature pdfSign = new Aspose.Pdf.Facades.PdfFileSignature();
pdfSign.BindPdf(pdf);

// Create the signature.
Aspose.Pdf.InteractiveFeatures.Forms.PKCS7 signature = new Aspose.Pdf.InteractiveFeatures.Forms.PKCS7(signatureFile, signaturePassword);

// Sign and save.
MemoryStream stream = new MemoryStream();
pdfSign.Sign(1, DigitalReason, DigitalContact, DigitalLocation, false, new Rectangle(), signature);
pdfSign.Save(stream);

return stream;
}


Sample code for Aspose.Pdf.Kit:

private Stream AddDigitalSignature(string pdfPath, string signatureFile, string signaturePassword)
{
Aspose.Pdf.Kit.PdfFileSignature pdfSign = new Aspose.Pdf.Kit.PdfFileSignature(pdfPath);

pdfSign.CertificationLevel = Aspose.Pdf.Kit.PdfFileSignature.CertifiedNoChangeAllowed;

Aspose.Pdf.Kit.Pkcs7Signature signature = new Aspose.Pdf.Kit.Pkcs7Signature(signatureFile, signaturePassword);
MemoryStream stream = new MemoryStream();
pdfSign.Sign(1, DigitalReason, DigitalContact, DigitalLocation, false, new Rectangle(), signature);
pdfSign.Save(stream);

return stream;
}

Hi there,


Thanks for your inquiry. After initial investigation, I’ve logged issue as PDFNEWNET-35256 in our issue tracking system for further investigation. We will update you about our findings via this forum thread.

Sorry for the inconvenience faced.

Best Regards,

Hi Chris,


Thanks for your patience. We are pleased to inform you that your reported issue is resolved in Aspose.Pdf for .NET 9.2.0. Please use following code to certify document with no change allowed state. It will help you to accomplish your requirements.

using (Document document = new
Document(myDir+“input.pdf”))<o:p></o:p>

{

using (PdfFileSignature signature = new PdfFileSignature(document))

{

PKCS7 pkcs = new PKCS7(myDir+"/your_pfx_file.pfx", "your_password");

DocMDPSignature docMdpSignature = new DocMDPSignature(pkcs, DocMDPAccessPermissions.NoChanges);

System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);

//set signature appearance

signature.SignatureAppearance = myDir + "asposelogo.jpg";

//create any of the three signature types

signature.Certify(1, "Signature Reason", "Contact", "Location", true, rect, docMdpSignature);

//save output PDF file

signature.Save(myDir+"output.pdf");

}

}


Please feel free to contact us for any further assistance.


Best Regards,

The issues you have found earlier (filed as PDFNEWNET-35256) have been fixed in Aspose.Pdf for .NET 9.3.0.

Blog post for this release can be viewed over this link


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan