Hi Aspose team,
I signed a PDF with a local certificate, then I attempted to view the signed PDF using Adobe Acrobat Std 2017. Acrobat states “At least one signature is invalid”. If you drill down into the signature details, the following is displayed.
image.png (41.1 KB)
I prepared the code sample, the test pdf and the certificate. Please have a look . Thanks.
FYI, we are using Aspoe.pdf v20.3 lib.
@Glority_Developer,
Thanks for contacting support.
We were able to notice the issue that you have mentioned and logged it as PDFNET-48017 in our issue tracking system. We will definitely look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.
We are sorry for the inconvenience.
Do you know when will this issue be fixed? This is a high priority issue and affects us a lot. Would it be included in the next month release? Thank you.
@Glority_Developer
I regret to inform that it is not possible to share ETA for now. I request for your patience and we will share good news with you soon.
Hi Aspose team,
We are going to have the code freeze date of our product. Did you have any progress on it? Will this issue be fixed within 1-2 months?
@Glority_Developer
We are afraid that there are no updates at the moment about issue resolution or ETA. The issue could not get investigated due to other issues in the queue logged prior to it. We will surely inform you once we have some certain news about its fix.
We apologize for the inconvenience.
@Glority_Developer
We have investigated the earlier logged ticket. You were “resaving” the document again (it was changing the modification time, metadata, …). The fixed code is:
string dataDir = "D:\\1\\";
string inputPDF = dataDir + "48017.PDF";
string inputPFX = dataDir + "48017.PFX";
string outputPDF = dataDir + "48017_signed.PDF";
var _document = new Document(inputPDF);
var pdfSign = new PdfFileSignature(_document);
var names = pdfSign.GetSignNames();
foreach (var name in names)
{
pdfSign.RemoveSignature(name);
}
_document.Save(outputPDF);
using (var fs = new FileStream(outputPDF, FileMode.Open, FileAccess.ReadWrite))
{
using (var doc = new Document(fs))
{
var pkcs = new PKCS7(inputPFX, @"123456")
{
Reason = @"WinZIp 666",
Location = @"WinZip 999"
};
var field = new SignatureField(doc.Pages[1], new Rectangle(0, 0, Convert.ToInt32(_document.Pages[1].PageInfo.Width), 100));
doc.Form.Add(field, 1);
field.Sign(pkcs);
//doc.Save();//in this place you "resave" document again(it changes modification time, metadata, ...)
}
}
We also recommend using the Facade model as it is easier to use:
string dataDir = "D:\\1\\";
string inputPDF = dataDir + "48017.PDF";
string inputPFX = dataDir + "48017.PFX";
string outputPDF = dataDir + "48017_signed_type2.PDF";
var _document = new Document(inputPDF);
var pdfSign = new PdfFileSignature(_document);
var names = pdfSign.GetSignNames();
foreach (var name in names)
{
pdfSign.RemoveSignature(name);
}
_document.Save(outputPDF);
using (var doc = new Document(outputPDF))
{
using (var signDoc = new PdfFileSignature(doc))
{
var pkcs = new PKCS7(inputPFX, @"123456");
var rect = new System.Drawing.Rectangle(0, 0, Convert.ToInt32(doc.Pages[1].PageInfo.Width), 100);
signDoc.Sign(1, @"WinZIp 666", "Contact", @"WinZip 999", true, rect, pkcs);
signDoc.Save(outputPDF);
}
}