I have a problem. I'm developing a program in which I can read .p12 and .pfx files. My code is the following:
const pathSignFile = await uploadFile(signFile, ['p12', 'pfx'], '/signCerts');
const signBufferBinary = fs.readFileSync(pathSignFile, { encoding: 'binary' });
const data = isSignValidity(signBufferBinary, signPassword);
return res.status(200).json({
data
});
With some files I can access it, but in others the error lies here:
const asn1 = forge.asn1.fromDer(p12base64);
const p12 = forge.pkcs12.pkcs12FromAsn1(asn1, false, password);
return p12
The result I have is this:
{
"byteCount": 3891,
"remaining": 6
}
And status 500.
I tried:
const p12Der = forge.util.decode64(certOrPfx.toString('base64'));
const p12Asn1 = forge.asn1.fromDer(p12Der);
It didn't work.