LibreSign / LibreSign/libresign

Unable to sign document after editing PDF

Open
#3,949 29 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
818
Forks
146
Avg merge
11h 31m
Merged PRs (30d)
326

Description

Is your feature request related to a problem? Please describe.
After editing a PDF in the browser to highlight something or insert an image, LibreSign throws an error when I try to sign the document: "Internal error. Please contact an administrator."

In the Nextcloud log, I find a lot of entries related to this action:

[libresign] Fehler: [{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Handler\/JSignPdfHandler.php","line":105,"function":"signWrapper","class":"OCA\\Libresign\\Handler\\JSignPdfHandler","type":"->"},{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Handler\/JSignPdfHandler.php","line":76,"function":"signUsingVisibleElements","class":"OCA\\Libresign\\Handler\\JSignPdfHandler","type":"->"},{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Handler\/Pkcs12Handler.php","line":133,"function":"sign","class":"OCA\\Libresign\\Handler\\JSignPdfHandler","type":"->"},{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Service\/SignFileService.php","line":275,"function":"sign","class":"OCA\\Libresign\\Handler\\Pkcs12Handler","type":"->"},{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Controller\/SignFileController.php","line":129,"function":"sign","class":"OCA\\Libresign\\Service\\SignFileService","type":"->"},{"file":"\/var\/www\/nextcloud\/apps\/libresign\/lib\/Controller\/SignFileController.php","line":95,"function":"sign","class":"OCA\\Libresign\\Controller\\SignFileController","type":"->"},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":208,"function":"signUsingUuid","class":"OCA\\Libresign\\Controller\\SignFileController","type":"->"},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":114,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/App.php","line":161,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"\/var\/www\/nextcloud\/lib\/private\/Route\/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"\/var\/www\/nextcloud\/ocs\/v1.php","line":43,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"\/var\/www\/nextcloud\/ocs\/v2.php","line":7,"args":["\/var\/www\/nextcloud\/ocs\/v1.php"],"function":"require_once"}] POST /ocs/v2.php/apps/libresign/api/v1/sign/uuid/9e99a3a6-c111-4090-8b80-7dd41c630c5f von 2003:c1:9f04:6500:f329:f61d:e252:e99f von -- um 15.11.2024, 12:21:36 [libresign] Fehler: Error to sign PDF. ["FINE Default property file doesn't exists.","FINE Default property file doesn't exists.","INFO Checking input and output PDF paths.","INFO Getting key alias","INFO Used key alias: moritz busch","INFO Loading private key","INFO Getting certificate chain","INFO Opening input PDF file: \/tmp\/7b089a15366fcdc896a299330fbaf815.pdf","INFO Creating output PDF file: \/tmp\/7b089a15366fcdc896a299330fbaf815_signed.pdf","INFO Creating signature","SEVERE Problem occured","com.lowagie.text.DocumentException: Append mode requires a document without errors even if recovery was possible.","\tat com.lowagie.text.pdf.PdfStamperImp.(PdfStamperImp.java:123)","\tat com.lowagie.text.pdf.PdfStamper.(PdfStamper.java:130)","\tat com.lowagie.text.pdf.PdfStamper.createSignature(PdfStamper.java:707)","\tat net.sf.jsignpdf.SignerLogic.signFile(SignerLogic.java:204)","\tat net.sf.jsignpdf.Signer.signFiles(Signer.java:246)","\tat net.sf.jsignpdf.Signer.main(Signer.java:139)","","INFO Finished: Creating of signature failed."] POST /ocs/v2.php/apps/libresign/api/v1/sign/uuid/9e99a3a6-c111-4090-8b80-7dd41c630c5f von 2003:c1:9f04:6500:f329:f61d:e252:e99f von -- um 15.11.2024, 12:21:36

[libresign] Fehler: Error at JSignPdf side. LibreSign can not do nothing. Follow the error message: Error to sign PDF. ["FINE Default property file doesn't exists.","FINE Default property file doesn't exists.","INFO Checking input and output PDF paths.","INFO Getting key alias","INFO Used key alias: moritz busch","INFO Loading private key","INFO Getting certificate chain","INFO Opening input PDF file: /tmp/7b089a15366fcdc896a299330fbaf815.pdf","INFO Creating output PDF file: /tmp/7b089a15366fcdc896a299330fbaf815_signed.pdf","INFO Creating signature","SEVERE Problem occured","com.lowagie.text.DocumentException: Append mode requires a document without errors even if recovery was possible.","\tat com.lowagie.text.pdf.PdfStamperImp.(PdfStamperImp.java:123)","\tat com.lowagie.text.pdf.PdfStamper.(PdfStamper.java:130)","\tat com.lowagie.text.pdf.PdfStamper.createSignature(PdfStamper.java:707)","\tat net.sf.jsignpdf.SignerLogic.signFile(SignerLogic.java:204)","\tat net.sf.jsignpdf.Signer.signFiles(Signer.java:246)","\tat net.sf.jsignpdf.Signer.main(Signer.java:139)","","INFO Finished: Creating of signature failed."]
POST /ocs/v2.php/apps/libresign/api/v1/sign/uuid/9e99a3a6-c111-4090-8b80-7dd41c630c5f
von 2003:c1:9f04:6500:f329:f61d:e252:e99f von -- um 15.11.2024, 12:21:36

Describe the solution you'd like
Edit a document and then sign it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by editing a PDF in the browser and signing it, then inspect lib/Handler/JSignPdfHandler.php at the logged signing calls around lines 76 and 105. Trace the sign request through SignFileService.php and compare the JSignPdf error with the edited input. Done means an edited PDF can be signed successfully without the internal error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.