node-signpdf | Simple signing of PDFs in node | Runtime Evironment library
kandi X-RAY | node-signpdf Summary
kandi X-RAY | node-signpdf Summary
Simple signing of PDFs in node.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Get a page ref reference
- Extract pages from a page
- interpolate default module
node-signpdf Key Features
node-signpdf Examples and Code Snippets
Community Discussions
Trending Discussions on node-signpdf
QUESTION
i was looking for a solution to digitally sign a pdf with a self-signed certificat and came across a video in youtube explaining the process using pdf-lib and node-signpdf libraries. However, after following the instructions it didnt work as intended and encountered a problem:
- i executed the command ( npm i ) and (npm start ) as shown in the github repo of the project.
repo : https://github.com/RichardBray/pdf_sign
Demo ( 8 mins video ) : https://www.youtube.com/watch?v=OFZK5lc70OI&list=PLXUfmx2SIgyICZP-rA84Sle_ghq30W89N&index=4&t=1s
...ANSWER
Answered 2022-Mar-27 at 19:41it appears that the problem is OS related. In fact , the code works fine under linux OS but have some issues with Windows OS related to import command. For windows OS replacing "import" commands with "require" commands solves the problem.
BEFORE:
QUESTION
I use a modified version of this library: https://github.com/vbuch/node-signpdf#readme in an angular app to sign a pdf with a signature that has been created elsewhere. When I open the signed pdf with foxit reader the signature is invalid with the following message:
Unexpected byte range values defining scope of signed data
Any ideas what the problem could be?
Here is the file: https://drive.google.com/file/d/1eS2waysotpAx6VtHMNvhGvl3wqgiyoT7/view?usp=sharing
...ANSWER
Answered 2020-Nov-16 at 14:56I couldn't reproduce the “Unexpected byte range values defining scope of signed data” error message with the first example document, Foxit "merely" complained that the signature was invalid. Which it indeed is because you forgot to base64-decode the signature string before injecting it into the PDF - PDF requires the embedded signature containers in DER format.
Second Example DocumentThe second example document was shared in a comment:
Now I don't get the error about the byte range anymore but I get new errors: "The document has been altered or corrupted since the Signature was applied." and "The Signer's identity is invalid because it has expired or is not yet valid." and "The signature includes an embedded timestamp but it could not be verified." Not sure if I'm doing it correctly now. This is the new file: https://drive.google.com/file/d/1vsa7thwCsi04r68cdcIsfJG7cT2__-d9/view?usp=sharing
Indeed, the signature container now is injected in DER format, so Foxit Reader can validate it. Concerning the new error messages:
"The document has been altered or corrupted since the Signature was applied." - this indicates here that there is some digest value mismatch.
Calculating and extracting the digest values in question shows that the SHA256 digest value of the signed byte ranges of the document is
QUESTION
I'm using this library https://github.com/vbuch/node-signpdf to sign a pdf document. After I have signed the document I can see the signature when I open the pdf with Foxit reader but not when I open it with Adobe reader DC. I also tried Adobe reader XI but there I can't see it either.
When I open the document in pdf xchange viewer I get this error: non critical errors detected in the xref table.
Any ideas what the problem could be?
That's the file I signed: https://drive.google.com/file/d/1AZvS4sP2Y3FwW4Deod87Dgxc9I0QZkoc/view?usp=sharing
...ANSWER
Answered 2020-Nov-03 at 17:57In your example PDF the name of the signature field consists of 10 bytes, 9 bytes with value 0x00 and one byte with value 0x01. Apparently Adobe Reader does not like that field name.
After some experiments it looks like Adobe Reader does not like a field name starting with a 0x00 byte.
Maybe it contains some code that determines string lengths in a c'ish manner and interprets a 0x00 as end-of-string. A field name with a leading 0x00 byte, therefore, is interpreted as empty string, a field name not accepted by Adobe Reader either.
Thus, please use a signature field name made of (in particular starting with) some meaningful characters. As validators usually display the name of the signature field, this is a good idea anyways.
In terms of lowlevel PDF objects:
The signature field object looks like this:
QUESTION
- Sign a PDF in the browser using cliets certificate store or Smart Card
- For accessing the local cert store I use FortifyApp.
- Pdf is pre-signed on the server using iText(Sharp), then sent to the client via Ajax. Relevant code:
ANSWER
Answered 2020-Jun-29 at 08:51So I figured it out.
Can I achieve my goal without having to manually upload a p12/pfx file, is it even possible?
Yes, it is. (See below on what needs to be changed.)
Is the server-side implementation of the deferred signature correct, do I need something else?
Yes, the code above is fine.
Is the pdf manipulation in javascript correct?
Also fine.
Can I transform the native CrytpoKey to forge or pkijs?
Yes, see below.
What is wrong with the last signature?
@mkl answered it in a comment, thank you.
FortifyApp has a CMS demo now. Although it didn't work with the version I was using, it works with version 1.3.4.
So I went with the pki.js implementation. The code changes need for the signing to be successful are the following:
- Export the certificate:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-signpdf
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page