Reputation: 668
I've tried with several p12 certificates and when I sign via my Nodejs approach it returns an invalid signature on Adobe.
However, signing just with Adobe the signature seems to be valid (just with a warning).
Is there something that I'm missing?
const signer = require('node-signpdf')
const fs = require('fs')
const helpers = require('node-signpdf/dist/helpers')
const init = async () => {
const p12Buffer = fs.readFileSync(`${__dirname}/cert.p12`);
let pdfBuffer = fs.readFileSync(`${__dirname}/test.pdf`);
pdfBuffer = helpers.plainAddPlaceholder({
pdfBuffer,
signatureLength: 31280,
});
pdfBuffer = signer.default.sign(pdfBuffer, p12Buffer, {
passphrase: 'reingenio'
});
fs.writeFileSync(`${__dirname}/signed.pdf`, pdfBuffer)
}
init()
Thanks.
Upvotes: 0
Views: 960
Reputation: 1
Did you tried read the pdf file as binary ?
fs.readFileSync(${__dirname}/test.pdf
, 'binary');
Upvotes: 0