-
Notifications
You must be signed in to change notification settings - Fork 832
Description
As of version 1.3.2, trying to get PKCS12 now throws this for valid untampered certificates that used to work before:
Error: Invalid PKCS#12. macData field present but MAC was not validated.
at p12.pkcs12FromAsn1 (/home/dmitrii/src/forge-repro/node_modules/node-forge/lib/pkcs12.js:479:11)
at getP12 (file:///home/dmitrii/src/forge-repro/index.js:30:28)
at parseCertificate (file:///home/dmitrii/src/forge-repro/index.js:9:15)
at file:///home/dmitrii/src/forge-repro/index.js:6:13
Find attached example.pfx (.debug added to satisfy GitHub filetype filter), generated in my personal Azure Key Vault (self-signed), with no password set.
I am using the following code to attempt to get PKCS12 object out of it:
import forge from "node-forge";
import { readFile } from "fs/promises";
// normally we'd use @azure/keyvault-secrets to get PFX as Base64 directly from AKV
const pfx = await readFile("./example.pfx");
const base64Pfx = pfx.toString("base64");
const p12Der = forge.util.decode64(base64Pfx);
const p12Asn1 = forge.asn1.fromDer(p12Der);
const p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1);In v1.3.1 this works as expected.
In v1.3.2 this throws the error above.
The certificate itself is not tampered with in any way, and works fine with OpenSSL directly, as well as similar libraries in C# and Python.
Is the check added in pkcs12.js to address the recent CVE issue too overzealous, trying to cover for cases it shouldn't be touching?