vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
696 stars 175 forks source link

Double signature #74

Closed machanics closed 4 years ago

machanics commented 4 years ago

Hello! Tell me how to sign a document 2 times ? after signing, the first signature becomes invalid (signature byte range is invalid)

therpobinski commented 4 years ago

Can you share the pdf you are using? I think I know what happens, before signing a "placeHolder" is added that allows us to size where the signature will be placed. If it is not dimensioned with the bytes that correspond to the length of the signature, the error it mentions occurs.

machanics commented 4 years ago

Good afternoon, I figured out this problem yesterday. If there is more than 1 signature in the document, there must be a mandatory ID value

trailer
<< /Size 8
/Root 1 0 R
/ID [ <F7D77B3D22B9F92829D49FF5D78B8F28>
<F7D77B3D22B9F92829D49FF5D78B8F28> ]
>>
startxref
97631
%%EOF

I think it would be nice to add a check to the function plainAddPlaceholder

vbuch commented 4 years ago

About the /ID attibute, please read this answer: https://stackoverflow.com/a/20091203/2528232

vbuch commented 4 years ago

Could #75 and #76 be related here?

Any additional findings on the /ID attribute, @mechanics?

therpobinski commented 4 years ago

Yes, this problem has a lot to do with the 'issues' mentioned above.

Now that it has been resolved but now we have another problem, I see that this new problem has been mentioned in several cases but it has not been completely resolved.

imagen

When reviewing the Buffer, I have noticed something, I want to get rid of the doubts. Can't the objects created by each tag be repeated? Because if the answer is negative, then there is an error in the location of the placeholder. I see that the /Type /AcroForm object is occupying the identifier 26 0 obj, this identifier was already occupied almost at the beginning of the PDF. And this object is on the page that has been removed from the PDF and I get the error that it cannot validate the signature. If the object identifiers cannot be repeated, then there is an error putting the AcroForm signature. I am right?

Or, I think the 2 AcroForm signatures should carry the same object ID, right?

I also mentioned this in this isuue which was closed. @vbuch, Can you help me with this concern?

therpobinski commented 4 years ago

issue solved

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity in the past 90 days. It will be closed if no further activity occurs. Thank you for your contributions.