LibreSign / libresign

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

"Internal Error" when signing document in v8.0.0-rc8 #2535

Closed DazeEnd closed 3 months ago

DazeEnd commented 3 months ago

Describe the bug When a logged in user attempts to sign a document (using "click to sign"), an internal error prevents the document from being signed.

To Reproduce

  1. While logged into Nextcloud as an admin user, request a signature on a document from a regular Nextcloud user.
  2. Log out of Nextcloud.
  3. Log into Nextcloud as the regular user that received the signature request.
  4. Open the LibreSign app, select the document from step 1, and click the "Sign" button.
  5. Define your signature, if it hasn't yet been done.
  6. Click the "Sign the document" button, then click the "Confirm" button.

Expected behavior The document should be successfully signed.

Actual behavior A message appears that reads, "Internal error. Contact admin."

Screenshots Screenshot from 2024-03-18 18-39-32 image image

Environment information (please complete the following information):

Additional context N/A

DazeEnd commented 3 months ago

I just noticed that LibreSign creates a filename.signed.pdf file, even though the signature fails, and the document status is "available for signature". image

vitormattos commented 3 months ago
Screenshot 2024-03-18 at 22 47 24 Screenshot 2024-03-18 at 22 46 51

Internal server error (422 error code), when trying to sign the document

Originally posted by @glimz in https://github.com/LibreSign/libresign/issues/2109#issuecomment-2005054930

@glimz is this reported related with this issue? Did you made the same steps?

vitormattos commented 3 months ago

Making a quick look at your log I identified that:

Error at JSignPdf side. LibreSign can not do nothing. Follow the error message: Certificate is Empty or Invalid.

https://github.com/LibreSign/libresign/blob/a9395eb3b42dd2918bacc20c472df19d06070b58/lib/Handler/JSignPdfHandler.php#L140

The messageCertificate is Empty or Invalid is made by JSignPdf and is because JSignPdf don't found the .pfx file. The default folder of .pfx file is LibreSign/signature.pfx. I will check if have a point that don't cover the scenario to get the content of signature.pfx file to generate the problem that JSignPdf receive an empty or not found certificate file.

This is a good start point, I will look more to identify what happening.

DazeEnd commented 3 months ago

So do you think this is a bug, or is this a configuration problem with my installation? I can try to reinstall if you think the problem is on my end.

vitormattos commented 3 months ago

I need to make more tests because you aren't the unique reporting this problem. I will check what I can do to give best reports to prevent this internal error.

vitormattos commented 3 months ago

An error that I also need to try to reproduce that stay in your log is this:

Undefined array key \"profileElementId\"

In my development environment I already put a breakpoint at the point that this error was trigged but I don't identified a way to reproduce this error.

I think that haven't relation with certificate but, since that visible elements is stored at filesystem, could have relation.

DazeEnd commented 3 months ago

Just an update: I reinstalled Nextcloud and LibreSign v8.0.0-rc8. After reinstalling, I still get the same error.

vitormattos commented 3 months ago

I think that this is the same that was solved by:

Was a logic problem when try to sign without password certificate.

vitormattos commented 3 months ago

This:

Fixes:

An error that I also need to try to reproduce that stay in your log is this:

Undefined array key \"profileElementId\"

In my development environment I already put a breakpoint at the point that this error was trigged but I don't identified a way to reproduce this error.

I think that haven't relation with certificate but, since that visible elements is stored at filesystem, could have relation.

vitormattos commented 3 months ago

Fixed at https://github.com/LibreSign/libresign/releases/download/v8.0.0-rc9/libresign-v8.0.0-rc9.tar.gz

DazeEnd commented 3 months ago

This is fixed for me in v8.0.0-rc9.