LibreSign / libresign

✍️ Nextcloud app to sign PDF documents
https://libresign.coop
GNU Affero General Public License v3.0
480 stars 56 forks source link

possible large file not able to sign #1917

Closed manuelkamp closed 5 months ago

manuelkamp commented 11 months ago

Describe the bug Error whle signing a pdf with 120 pages.

To Reproduce Steps to reproduce the behavior: sign as usual a large pdf, error occurs.

Expected behavior being able to sign also large files.

Screenshots na

Environment information (please complete the following information):

vitormattos commented 11 months ago

What's the size of this PDF to be possible reproduce? For now, at current version of LibreSign, the project JSignPdf is used to sign a document, if is possible, would you do a test locally using JSignPDF to check if is possible to sign your large file?

vitormattos commented 11 months ago

Spoiler: Only a random comment, probability, in the next version of LibreSign, will be possible change the sign engine at admin area between JSignPDF or this package: https://github.com/jeidison/pdf-signer-php

manuelkamp commented 11 months ago

in file size it is 3,5mb, it has 138 pages, a lot of references, links, images etc. (it is one of my bachelor thesis i wrote in ms word-i think it was ms word 2013 back then - and safed there as pdf). I also found another documents (single pagers) which fails with "Impossible get metadata from this file." from that same time era - maybe it is a legacy issue in pdf somehow... but yes, I am willing to test it further, if you consider it helpful.

random reaction :) I prefer to not have a docker container, since I am running another container solution (LXC) and I see no sense in having docker inside of lxcs. but just a personal opinion. It is sometimes hard to install docker solutions bare metal in lxc ;)

vitormattos commented 11 months ago

Dockrer isn't a requirement to use LibreSign. If you prefer, ou can use LXC.

I will like if you would do a test using JSignPDF.

About metadata, this is in another part of LibreSign and maybe this already was fixed. If persist in your environment, would be good to create another issue.

manuelkamp commented 11 months ago

let me first reply to the docker thing: i was referring to pdf-signer-php, which seems to be a dockerized solution.

now to the main point: I tested it now (sorry had to watch f1 yesterday evening) with the binaries used by libresign and it signed successfull...(sorry for german output, but it says "Done: Signature done successfull" in the last line.

root@srv-cloud:/media/SSD/ncdata/appdata_ocxlxs84rbah/libresign/jsignpdf-2.2.0# /media/SSD/ncdata/appdata_ocxlxs84rbah/libresign/java/jdk-17.0.5+8-jre/bin/java -jar /media/SSD/ncdata/appdata_ocxlxs84rbah/libresign/jsignpdf-2.2.0/JSignPdf.jar -kst PKCS12 -ksf /media/SSD/ncdata/manuel/files/.Signing/signature.pfx -ksp "topsecret" -ka manuel /media/SSD/ncdata/manuel/files/Documents/FH/Bachelorarbeit/thesis.pdf
FEIN Default property file doesn't exists.
FEIN Default property file doesn't exists.
INFORMATION Checking input and output PDF paths.
INFORMATION Hole Schlüssel Alias
INFORMATION Verwendet Schlüssel: manuel
INFORMATION Lade privaten Schlüssel
INFORMATION Hole Zertifikatskette
INFORMATION Öffne PDF Eingabedatei: /media/SSD/ncdata/manuel/files/Documents/FH/Bachelorarbeit/thesis.pdf
INFORMATION Erzeuge PDF Ausgabedatei: ./thesis.pdf
INFORMATION Erzeuge Signatur
INFORMATION Setze Zertifizierungsstufe
INFORMATION Bearbeite (es kann ein wenig länger dauern) ...
INFORMATION Schließe erzeugten PDF Stream
INFORMATION Fertig: Signatur erfolgreich erzeugt

I checked again with Libresign (the same file) and it results in error "unknown error", finding this in the logs: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) at /var/www/nextcloud/apps/libresign/vendor/libresign/tcpdi_parser/src/tcpdi_parser.php#891

regarding the second issue i found this in the logs (so we consider that as feature, nut a bug ;) ): Impossible get metadata from this file: Secured pdf file are currently not supported.

vitormattos commented 11 months ago

About PDF-signer: isn't a dockerized solution, have a docker-compose only to development environment and to make easy to help at development. This a PHP package installed by composer.

Don't worry about German, English also isn't my main language. The important is to send the message that we want as the right way and get the right understanding, if we identify that the meaning is wrong, is time to fix :-) Like about php-pdf. Sometimes the application of words won't will be the best because in my language or in your native language we have specific usages of words that isn't easy to translate to English.

Following about the subject of this issue...

Looking the error message, sounds that the problem is about configuration of your PHP. At this time the PDF file is stored at variable and will be necessary to have a memory_limit at your php.ini file that can store besides the memory to run Nextcloud, more allowed memory to store the PDF content. A workaround that you can do is set this to -1 and run again your test.

PS: Today is 31'th October, the day that Martin Luther, a very important man to German culture, did a imporant step that changed the German culture. As you a German man, I send my congratulations to you about this day.

manuelkamp commented 11 months ago

I am not from Germany, I am from Austria (we speak German too) :)

Regarding the memory_limit of PHP. It is currently set to 1GB (memory_limit = 1G), I am using PHP 8.1.25 (fpm), max_execution_time = 3600, post_max_size = 10240M. I set memory_limit = -1 and restarted. The result is not positive. It raises RAM consumation until maximum (16GB) and then crashes completely php-fpm service:

 php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
     Active: failed (Result: oom-kill) since Tue 2023-10-31 16:00:05 CET; 1min 52s ago
       Docs: man:php-fpm8.1(8)
    Process: 174118 ExecStart=/usr/sbin/php-fpm8.1 --nodaemonize --fpm-config /etc/php/8.1/fpm/php-fpm.conf (code=exited, status=0/SUCCESS)
    Process: 174169 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, sta>
    Process: 174513 ExecStopPost=/usr/lib/php/php-fpm-socket-helper remove /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, statu>
   Main PID: 174118 (code=exited, status=0/SUCCESS)
     Status: "Processes active: 1, idle: 49, Requests: 234, slow: 0, Traffic: 2.3req/sec"
        CPU: 44.419s

Okt 31 15:58:27 srv-cloud systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...
Okt 31 15:58:27 srv-cloud systemd[1]: Started The PHP 8.1 FastCGI Process Manager.
Okt 31 16:00:03 srv-cloud systemd[1]: php8.1-fpm.service: A process of this unit has been killed by the OOM killer.
Okt 31 16:00:05 srv-cloud systemd[1]: php8.1-fpm.service: Failed with result 'oom-kill'.
Okt 31 16:00:05 srv-cloud systemd[1]: php8.1-fpm.service: Consumed 44.419s CPU time.
vitormattos commented 10 months ago

Will be necessary, from development side, to generate a big PDF file and check what happening and what will be necessary to fix this problem.

All changes only will come in the next version of LibreSign and have more info here about next version:

vitormattos commented 5 months ago

Could you check again at the newest release of LibreSign?

I made a lot of improvements. To test I signed the bible with 100 signers, worked fine to me.

Closing this issue as solved.

If this issue persists, don't hesitate to open a new issue making reference to this.

[!NOTE]

If you like this app, don't hesitate to help us

Ways to help this project: