Skip to content
Advertisement

PDF Signature invalid but Verfiy Signature with PDFBox2 is valid (true)

Sample PDF download: https://drive.google.com/file/d/12wv1Pb7gh4vCKOGhX4cZ3aOrLSiOo4If/view?usp=sharing

So when the PDF is opened in A.Reader (Contineous release) it says the Certificate is invalid as Changes have been made to this document that rendered the signature invalid.

But I can’t see what/where is changed. Only a Signature (certificate) was added with our own application that adds correct signatures for thousands of other PDFs. No other changes performed. Verifying the Hash with our own code or using PDFBox2 with following code says the signature is valid (true).

So why is A.Reader complaining?

Any help much appreciated as I’m banging my head to the wall for some days now…

JavaScript

Advertisement

Answer

Broken Cross References in First PDF Revision

The cross reference table at the end of your first revision looks like this:

JavaScript

As you can see it consists of multiple subsections with object numbers 0..18, 20..45, 48, and 50..51. In particular there is no mapping for object numbers 19, 46, 47, and 49.

This is disallowed for two reasons:

  • For a file that has never been incrementally updated, and so in particular for the first revision of each PDF file, the cross-reference section shall contain only one subsection, whose object numbering begins at 0.

  • The cross-reference table (comprising the original cross-reference section and all update sections) shall contain one entry for each object number from 0 to the maximum object number defined in the file, even if one or more of the object numbers in this range do not actually occur in the file.

(ISO 32000-1 section 7.5.4 “Cross-Reference Table”)

Thus, the first cross reference table of a regular PDF must consist of only a single subsection. And even if that was not required, gaps with unmapped object numbers are not allowed.

Normally Adobe Reader ignores violations of these requirements, but in the context of signature validation it is stricter. Usually this shows in situations where the PDF in question is signed and then some arbitrary incremental update is added.

For example, I took your first revision (the first 114510 bytes of your file) and signed them and then extended them to LTA:

only signed signed and extended
only signed signed and extended

This has been the topic in multiple questions here on stack overflow:

Additional Problems

There most likely are other issues still to be found in your example PDF, though. As mentioned above, cross references like in your first revision usually only cause problems after adding an incremental update to the signed PDF. That is not the case for your example PDF. Thus, I would expect other oddities in it.

Remarks

Some additional observations:

  • Starting from the first revision you have a number of extra entries in the document information dictionary: SIG_PAGE, SIG_LLX, SIG_LLY, SIG_URX, and SIG_URY. IMO this is not the appropriate place, although conforming readers may store custom metadata in the document information dictionary, they may not store private content or structural information there. Such information shall be stored in the document catalogue instead. (ISO 32000-1 section 14.3.3 “Document Information Dictionary”) IMO those entries look like processing instructions private to your work flow, not metadata of public interest.

  • Your signature dictionary contains a R value. Since PDF 1.5 this entry shall not be used, and the information shall be stored in the Prop_Build dictionary. (ISO 32000-1 table 252 “Entries in a signature dictionary”)

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement