Closed arenoir closed 8 months ago
Forcing the encoding while reading the p12 certificate was the issue. The binary p12 bundle now works and does not need to be encoded to DER encoding.
const CERTIFICATE = readFileSync(SIGNATURE_CERTIFICATE_PATH, 'utf8');
const CERTIFICATE = readFileSync(SIGNATURE_CERTIFICATE_PATH);
Describe the bug and the expected behaviour Unable to sign pdf using a self signed p12 certificate in node v20.9.0
Is it a bug in signing or in the helpers? It appears that @signpdf/signer-p12/dist/P12Signer.js is not able to use certificates greater than 32 bit?
To Reproduce Generate a DER encoded p12 certificate.
openssl req -x509 -newkey rsa:2048 -keyout wp.key -out wp.crt -days 36500 -nodes
openssl pkcs12 -export -out wp.p12 -inkey wp.key -in wp.crt -passout pass:
convert it to DER encoding (fixes the error "Error: Unparsed DER bytes remain after ASN.1 parsing.")openssl pkcs12 -in wp.p12 -out wp.der -passin pass: -passout pass: -nodes
Attempt to sign pdf using @signpdf/signpdf, @signpdf/signer-p12, @signpdf/placeholder-pdf-lib using node v20.9.0
signPDF.sign throws the following error
I am guessing there is something wrong with the certificate? Are there any guides on generating a valid p12 certificate?