You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2017/05/26 13:10:04 UTC

[jira] [Commented] (PDFBOX-3811) Problem with calling "saveIncrementalForExternalSigning" more than once in the same document

    [ https://issues.apache.org/jira/browse/PDFBOX-3811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16026266#comment-16026266 ] 

Tilman Hausherr commented on PDFBOX-3811:
-----------------------------------------

Here's what happens: in {{addSignature}} there is this line:
{code}
sigObject.setByteRange(new int[] { 0, 1000000000, 1000000000, 1000000000 });
{code}
This reserves the space. Now in {{COSWriter.doWriteSignature}} there are these lines:
{code}
        // Assign the values to the actual COSArray, so that the user can access it before closing
        byteRangeArray.set(0, COSInteger.ZERO);
        byteRangeArray.set(1, COSInteger.get(beforeLength));
        byteRangeArray.set(2, COSInteger.get(afterOffset));
        byteRangeArray.set(3, COSInteger.get(afterLength));
{code}
So the next time you do your external signing, the array has the actual values and this a shorter length.

I'm not yet sure what to do. Putting the initialisation elsewhere might bring another unwanted surprise.

> Problem with calling "saveIncrementalForExternalSigning" more than once in the same document
> --------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-3811
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3811
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Signing
>    Affects Versions: 2.0.6
>         Environment: Java 1.8
>            Reporter: Le Duc Duy
>            Priority: Trivial
>              Labels: easyfix, signature, signing
>         Attachments: PDFBoxTest.java, Screen Shot 2017-05-26 at 6.39.10 PM.png
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> I've included the test which will fail.
> After digging around a little, I found out that by calling saveIncrementalForExternalSigning, it trimmed the reserved space in the ByteRange (I've included the difference in the screen shot).
> I'm not sure if this is a bug for anyone but it's for my use case (distributed digital signing). Changing the content at all is not permitted at all. 
> If this is an intended feature, please dismiss this. I can workaround by calling it more than once and it'll be stable although I'm not sure about efficiency.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org