-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signing PDF with annotations results in invalid signature #50
Comments
Can you add some examples code and the resulting PDF files? |
@vanbroup Sure: Working PDF
PDF download: working.pdf Failing PDF
The only difference is that this PDF contains a Link annotation PDF download: failing.pdf ReproI am using this code for signing the PDF: pdfSign.Sign(bytes.NewReader(pdf), pdfWriter, pdfReader, pdfLen, pdfSign.SignData{
Signature: pdfSign.SignDataSignature{
CertType: pdfSign.CertificationSignature,
DocMDPPerm: pdfSign.AllowFillingExistingFormFieldsAndSignaturesAndCRUDAnnotationsPerms,
Info: pdfSign.SignDataSignatureInfo{
Name: "Test Signing",
Reason: "Demonstrating signing failures",
Location: "The Internet",
ContactInfo: "Twometer",
Date: time.Now(),
},
},
DigestAlgorithm: crypto.SHA384,
Signer: certs.key,
Certificate: certs.cert,
CertificateChains: [][]*x509.Certificate{certs.chain},
}) Here is the full repro code: https://gist.github.com/Twometer/d6611dee04132251531fbc2962190388 More infoThe only difference I can see in those PDFs raw streams is the line
being present in the Page object. (And of course some changes to the signature and the xref table) |
Thanks for these details @Twometer. I couldn’t find your unsigned file right away, but I’ve just released a new version that should address your issue. Could you please verify if it works? |
Thanks @vanbroup, I have just tested the new version ( Do I have to change any settings in the signing configuration? The unsigned file is created dynamically in the repro code with gopdf, but i've also attached it here: failing-unsigned.pdf |
This doesn't happen with any of the test documents right? I have not been able to look at your source document yet but have you tried opening that with Acrobat and does it ask you to have the document when closing (this often happens when there is an issue in the source document). Also, do you know if the document has an xref table or stream? I did do most testing with the tables and less with the streams for now. |
I've tried I've also tried opening and closing multiple source files in Adobe, and never got a saving prompt. My source document has just a regular xref table at the end of the document, no xref streams. |
The only difference I can see between the test document and my document is that the |
I have the exact same problem, any progress on this issue? My PDF Is also generated with gopdf, and fails when there is a link annotation in the PDF. |
The signature has been invalidated because Adobe is repairing the original document. As @Twometer noted, the page annotations created by gopdf are written as an embedded annotation that needs to be an indirect reference instead:
|
@vanbroup I have found the same paragraph in the spec, so I forked gopdf to write the annotations object correctly but I still got the same error message. |
Do you have a copy of the file with the correct PDF syntax? |
So that mean "/Annots" are not the root of the issue? |
This is great news! Thanks for testing! It would be great if you could contribute your fix back to gopdf to help others. |
I can't remember that Foxit Reader complained about any other signed documents. Is it only with the file created by gopdf? |
I tried it with So Foxit at least has weird behavior also on signed non-gopdf files. |
Let me investigate any issues with Foxit Reader, it used to validate correctly. |
@Twometer please check with the lasted version |
@vanbroup |
I have a PDF that was created with gopdf and contains Link annotations.
The PDF is then signed with pdfsign.
If I open the signed document in Adobe, it reports:
Without the link annotation, everything works fine and the PDF is shown as certified.
The text was updated successfully, but these errors were encountered: