Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signing a PDF with attachment results in a signed PDF without attachment #10

Closed
dhernandez opened this issue Jul 3, 2023 · 5 comments · Fixed by #27
Closed

Signing a PDF with attachment results in a signed PDF without attachment #10

dhernandez opened this issue Jul 3, 2023 · 5 comments · Fixed by #27

Comments

@dhernandez
Copy link

dhernandez commented Jul 3, 2023

I'm trying to sign a PDF with a zip file attached. The execution looks good and no errors are shown. Also, the signed PDF size is a bit higher than the original one, so the attachment should be there, but I cannot see it with any reader after signing.

Steps to reproduce:

$ rm -rf files_original files_signed && mkdir files_original files_signed

$ pdftk simple.pdf attach_files file.zip output simple_with_file.pdf
$ pdftk simple_with_file.pdf unpack_files output files_original
$ ls -hs files_original
total 876K
876K file.zip

$ ./pdfsign -name "Jon Doe" sign simple_with_file.pdf signed.pdf certificate.crt private_key.key
2023/07/03 11:59:45 Signed PDF written to signed.pdf
$ ./pdfsign verify signed.pdf | jq . | head -25
{
  "Error": "",
  "DocumentInfo": {
    "author": "",
    "creator": "",
    "hash": "",
    "name": "Jon Doe",
    "permission": "",
    "producer": "pdfcpu v0.4.1 dev",
    "subject": "",
    "title": "",
    "pages": 0,
    "keywords": null,
    "mod_date": "2023-07-03T11:59:44+02:00",
    "creation_date": "2023-07-03T11:02:31+02:00"
  },
  "Signers": [
    {
      "name": "Jon Doe",
      "reason": "",
      "location": "",
      "contact_info": "",
      "valid_signature": true,
      "trusted_issuer": true,
      "revoked_certificate": false,

$ pdftk signed.pdf unpack_files output files_signed
$ ls -hs files_signed
total 0
$ ls -hs simple.pdf file.zip simple_with_file.pdf signed.pdf
876K file.zip  928K signed.pdf   32K simple.pdf  904K simple_with_file.pdf
@vanbroup
Copy link
Member

vanbroup commented Jul 3, 2023

Does it work if you do not attach the zip file?

@dhernandez
Copy link
Author

Yes. Also, it "works" if I attach the file. I mean, I get no errors and the generated file is signed fine, but it does not contain the attached file anymore. Take a look at the output on my first comment.

@vanbroup
Copy link
Member

vanbroup commented Jul 3, 2023

I think this must be related to #4, a problem that needs further investigation but I haven't been able to fix yet.

Some help fixing #4 would be welcome, I do not expect to be able to fix this anytime soon.

@dhernandez
Copy link
Author

Ok, I understand this is not a priority.
Just to add some more info I think it is not related to #4, since my testing file has only one xref:

$ cat simple_with_file.pdf | grep -a startxref | wc -l
1
$ cat Acrobat_DigitalSignatures_in_PDF.pdf | grep -a startxref | wc -l
2

I've never worked with PDF files, so I do not think I can help. Anyway, I will take a look and try to figure out what is going on.

@dhernandez
Copy link
Author

I opened a PR to fix this issue. #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants