[
https://issues.apache.org/jira/browse/PDFBOX-2816?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14564867#comment-14564867
]
Petras commented on PDFBOX-2816:
--------------------------------
It appears that those two aforementioned changes caused Acrobat to invalidate
the previous signature. I made a patch with suggested changes to COSWriter and
PDDocument classes.
The patch:
* preserves indirect references to PDF array items;
* for non-visual signatures does not remove default resources (/DR entry) from
AcroForm, which might be already present;
* does not create optional appearance dictionary in Signature field's
annotation dictionary for non-visual signatures.
Additionally in this patch I also suggest a change in the way COSWriter
includes the objects to be written during incremental update. So far it was
that, even if indirect object of dictionary entry value or array item was
flagged with {{#setNeedToBeUpdate(true)}}, it was not included into the set of
the objects to be written, if the container was not flagged with
{{#setNeedToBeUpdate(true)}}. The patch checks the items of not-flagged
arrays/dictionaries, if they are indirect and have #needToBeUpdate flag set,
they are included into the set of objects to be written. For this current issue
it allowed to skip the rewriting of the page object when only the annotations
array (indirect object value of /Annots entry) was updated.
> PDFBox makes disallowed changes when signing a signed document
> --------------------------------------------------------------
>
> Key: PDFBOX-2816
> URL: https://issues.apache.org/jira/browse/PDFBOX-2816
> Project: PDFBox
> Issue Type: Bug
> Components: Signing
> Affects Versions: 1.8.9
> Reporter: Petras
> Attachments: acrosigned.pdf, acrosigned_signed.pdf
>
>
> It seems PDFBox make disallowed changes when signing a document containing a
> signature with visual appearance. Using the signing example
> {{org.apache.pdfbox.examples.signature.CreateSignature}} (modified to use BC
> 1.52) I signed (invisible signature) a document (_acrosigned.pdf_) containing
> signature with visual appearance. After signing Adobe Acrobat for the
> resulted pdf (_acrosigned_signed.pdf_) shows an error for the first
> signature: {quote}
> 1 Page(s) Modified
> Signature is invalid:
> Document has been altered or corrupted since it was signed.
> {quote}
> The first revision is intact after signing, but it seems PDFBox made some
> disallowed changes to the document. Adobe in its technical white paper [Adobe
> Acrobat 9 Digital Signatures, Changes and
> Improvements|http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/reader/pdfs/readercomp_digitalsignatures.pdf]
> disallows such changes for the signed document:
> * Adding form fields other than signature fields
> * Changing page content
> Unfortunately, I could not identify the changes which caused this error,
> though I notice these changes in structure after signing:
> # Default resources (/DR) were droped from AcroForm dictionary;
> # An array of annotation dictionaries (value of /Annots in page object)
> became direct;
> And probably there are more...
> I thought the first change was fundamental, noticed that
> {{PDDocument#addSignature()}} method removes /DR key for invisible
> signatures. Tried to disable it in 1.8.10-SNAPSHOT sources, but unfortunately
> it didn't help. Didn't tried to reuse the same array object for /Annots yet.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]