jsreport / jsreport-pdf-sign

jsreport extension for signing pdf outputs using certificate
GNU Lesser General Public License v3.0
4 stars 1 forks source link

Error: Signature exceeds placeholder length: 8612 > 8192 #1

Open DrT27 opened 4 years ago

DrT27 commented 4 years ago

Hello,

I get the above error message when trying to sign a pdf output. Is there a possibility to set the max length value in the configuration?

Best, Werner

pofider commented 4 years ago

It is currently hardcoded.

Would you please upload the pdf you are trying to sign so we can test it?

DrT27 commented 4 years ago

Hello, thank you for your quick reply. I tried with several report templates and think the error has to be related with the certificate itself. We use it in our company for different purposes and have no issues with it.

For proofing this I created a really short template (see img1) giving the same error message.

test_report_certificate_error

It is interesting that the certificate file has a size of 8,192 Bytes. So after importing it as an asset it seems the size has grown (8,612 Bytes)? I also tried different strings in the field "reason to filled in pdf", also leaving it empty. This has no effect on the size complained in the error.

test_certificate_error

pofider commented 4 years ago

Ah ok, so it is about the certificate itself.

It is interesting that the certificate file has a size of 8,192 Bytes. So after importing it as an asset it seems the size has grown (8,612 Bytes)?

I believe the stored certificate asset has still the same size. The 8,612 size is probably assembled after some crypting, random vectors...

Would you please try to increase the number here and try it again? https://github.com/jsreport/jsreport-pdf-sign/blob/0.3.0/lib/sign.js#L32

DrT27 commented 4 years ago

Thank you Jan for the answer! I took me a while to get back to it but it seems to work! I incresed the 8192 (2^13) to 16384 (2^14). Because we use a dockerized JsReport installation I had to restart the docker container, which made the changes effective.

Thank you for your time and advice! Best regards, Werner

pittam commented 3 years ago

Hi, Recently, we have deployed the JSReports in AWS Lambda but facing the same issue while signing the pdf.

Error: Error while executing pdf-utils operations. Signature exceeds placeholder length: 13138 > 8192

at module.exports (/Users/spittam/GDD/Projects/2020/aws/jsreportapp/node_modules/jsreport-core/lib/util/createError.js:11:13)

at Reporter.createError (/Users/spittam/GDD/Projects/2020/aws/jsreportapp/node_modules/jsreport-core/lib/reporter.js:332:12)

at AsyncFunction. (/Users/spittam/GDD/Projects/2020/aws/jsreportapp/node_modules/jsreport-pdf-utils/lib/main.js:382:22)

at runMicrotasks (<anonymous>)

at processTicksAndRejections (internal/process/task_queues.js:93:5)

caused by: Error: Signature exceeds placeholder length: 13138 > 8192

at SignPdf.sign (/Users/spittam/GDD/Projects/2020/aws/jsreportapp/node_modules/node-signpdf/dist/signpdf.js:145:13)

at module.exports.sign (/Users/spittam/GDD/Projects/2020/aws/jsreportapp/node_modules/jsreport-pdf-utils/lib/utils/sign.js:66:17)

at Object.postprocess (/Users/spittam/GDD/Projects/2020/aws/jsreportapp/node_modules/jsreport-pdf-utils/lib/utils/pdfManipulator.js:122:31)

at processTicksAndRejections (internal/process/task_queues.js:93:5)

at async module.exports (/Users/spittam/GDD/Projects/2020/aws/jsreportapp/node_modules/jsreport-pdf-utils/lib/scriptPdfProcessing.js:83:5)

at async scriptExecModuleWrapper (/Users/spittam/GDD/Projects/2020/aws/jsreportapp/node_modules/jsreport-core/lib/scriptExecModuleWrapper.js:34:20)

Any suggestions to fix the issue ? .