Conversation
A CertificationSignature produced a signature dictionary with the DocMDP transform — /Reference -> /TransformMethod /DocMDP -> /TransformParams /P — but the document catalog never gained the matching /Perms entry. ISO 32000-1 12.8.2.2 requires both: "The Perms entry in the document catalog dictionary shall contain a DocMDP entry whose value is the signature dictionary of that signature field." The /P value states the permission level; /Perms is what makes a conforming reader apply it. Without it the output is an ordinary approval signature. That failure is silent — the file still verifies, and tooling that reports the signature type still reports the DocMDP transform from the /Reference array — but Acrobat shows no "Certified by" bar and the /P restriction is not enforced. createCatalog already had the comment "Set SigFlags and Permissions based on Signature Type" over a switch that only ever wrote /SigFlags. SignData.objectId holds the signature dictionary's object number and is populated by addSignatureObject, which SignPDF runs before addCatalog, so the reference is available at the point the catalog is built. The new test signs testfile20.pdf both ways and asserts that a certification signature's /Perms /DocMDP resolves to the /Type /Sig object carrying /P 1, and that an approval signature writes no /Perms at all. It fails on the unpatched tree. The two CertificationSignature golden catalogs in TestCreateCatalog gain the entry, with the signature object number pinned so the expectation stays deterministic. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
CertType: CertificationSignaturewrites the DocMDP transform into the signature dictionary:but the document catalog never gains the matching
/Permsentry. ISO 32000-1 §12.8.2.2:Both halves are required. The
/Pvalue states the permission level;/Permsis what makes a conforming reader apply it.Without
/Perms, the output is an ordinary approval signature. The failure is quiet: the file verifies, and tools that report the signature type still find the DocMDP transform in/Reference— but Acrobat shows no "Certified by" bar and the/Prestriction is not enforced. Comparing apdfsign-certified file against an Adobe Acrobat Sign-certified one,/Perms<</DocMDP N 0 R>>in the catalog is the only structural difference.createCatalogalready carries the comment// Set SigFlags and Permissions based on Signature Typeover a switch that only ever writes/SigFlags, so this looks like an intent that was never finished rather than a deliberate omission.The fix
Six lines in
createCatalog.SignData.objectIdholds the signature dictionary's object number and is populated byaddSignatureObject, whichSignPDFruns beforeaddCatalog— so the reference is available exactly where it is needed, and no ordering change is required.There is no caller-side workaround:
PreSignCallbackruns before the signature object exists,UpdateObjectis overwritten by the catalogaddCatalogwrites afterwards, and a second incremental update would invalidate the signature it is trying to describe.Tests
TestCertificationSignatureSetsPermsDocMDPsignstestfiles/testfile20.pdfas both a certification and an approval signature and asserts that:/Perms /DocMDPresolves to the/Type /Sigobject, whose/Referencecarries/TransformMethod /DocMDPand/TransformParams /P 1;/Permsat all.It fails on the unpatched tree with "certification signature has no catalog /Perms". The two
CertificationSignaturegolden catalogs inTestCreateCataloggain the entry, with the signature object number pinned so the expectation stays deterministic.go build ./... && go vet ./... && go test ./...is green.Found while evaluating pdfsign for a PAdES certification seal over documents composed with pdfcpu. Happy to adjust the shape — e.g. gating it on
DocMDPPerm != 0, or emitting/Permsfor other cert types — if you'd prefer something different.