Copy link to clipboard
Copied
Hi all,
I am writing a C++ signature library which works fine so far, what means that Adobe Reader 2015.017.20053 shows the signature toolbar, including the green sign and "Signed and all signatures are valid".
Now, I add a comment line to the document before signing it with my library.
The signing algorithm and calculation of input data for the signature calculation stays as-is (so the comment is included in that data).
The comment breaks the signature verification, because now Adobe reader says "At least one signature is invalid", and in the signature panel it says "There are errors in the formatting or information contained in this signature (The signature byte range is invalid)".
Is there a special rule how to handle comments in signature calculation?
Or does Adobe reader verify those documents differently? Is there maybe a bug?
Aha! The insertion of comments between the startxref lines and %%EOF is specifically forbidden by a very specific rule that describes exactly what the two lines before %%EOF must be (see the Syntax > File Structure > File Trailer section of the spec). Of course not all readers will verify that this is done exactly right.
Copy link to clipboard
Copied
Have you confirmed that the commented PDF is error free? What technique do you use to add the comment?
Copy link to clipboard
Copied
Hi TestScreenName,
thanks for your quick response. About your questions:
Copy link to clipboard
Copied
1. The key thing would be to ensure that the file does NOT need to be repaired. Open it in Acrobat (NOT READER). Immediately close. If there is a save prompt, it needed repairing. However, I suggest this test on the file you present for signing - the unsigned file as well as on the signed file. If the file needs repairing, the repair will invalidate all the hashes.
2. This worries me. It does not sound viable, even though I know comments are permitted in the standard. Normally I'd just say it isn't viable because any editing tool may delete them - even a Save as will do so. But, coupled with the signature, that's detectable. Just seems unsafe to do that rather than use the object tree in the approved way.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Aha! The insertion of comments between the startxref lines and %%EOF is specifically forbidden by a very specific rule that describes exactly what the two lines before %%EOF must be (see the Syntax > File Structure > File Trailer section of the spec). Of course not all readers will verify that this is done exactly right.
Copy link to clipboard
Copied
You´re great!
Placing the comment BEFORE the trailer block did the trick. Now Adobe reader reports 'signature valid' again.
It´s a pity that Adobe reader does not tell the user that there is a violation of the PDF standard when it is confronted with the comment before the %%EOF mark...
I will do a try-out to see whether it also works when I insert the comment e.g. at the beginning of the document or inside an object.
Copy link to clipboard
Copied
Years ago, Acrobat would detect and report certain kinds of error from which it could recover (like bad page streams). For some reason, it now just stops processing the page with no error message at all, perhaps showing partial content. I don't like that. Certainly, Acrobat isn't any kind of validator (except, of course, of signatures).
Find more inspiration, events, and resources on the new Adobe Community
Explore Now