vbuch / node-signpdf

Simple signing of PDFs in node.
MIT License
719 stars 178 forks source link

Error when signing with certificate containing latin characters #89

Closed wesleimarinho closed 3 years ago

wesleimarinho commented 4 years ago

When a certificate containing latin characters is used, the signature is corrupted (or in some PDF readers, such as Foxit Reader, it says the document has been altered since signature).

I imagine it's not a problem with the helpers.

Example certificate is attached, it has the brazilian state name "São Paulo": latin.zip - the provided sample certificate has a blank password.

The same behavior has been identified using any certificate data containing latin characters.

Kyryn commented 4 years ago

We have same problem with latin characters ěščřžýáíé

vbuch commented 4 years ago

Can't remember from top of my head but probably an assumption of utf-8 is made somewhere in the code. The placeholder should be irrelevant as it doesn't care of certificates. Certificates come when it comes to signing. So it is either in the signing code (which is roughly 200 lines of easy to read code) or in node-forge (which could be quite an issue to debug).

wesleimarinho commented 4 years ago

I think it is not related to placeholders. I face the same behavior when using the mentioned certificates and pdf-lib to add the placeholders.

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.

LuanMaik commented 3 years ago

I gave up and created the solution using Java and PDFBox lib. This link show how to implement the solution in java: https://jvmfy.com/2018/11/17/how-to-digitally-sign-pdf-files/