const pkcs12 = forge.pkcs12;
const pkcs12Der = arrayBufferToString(pfxData)
const p12Asn1 = forge.asn1.fromDer(pkcs12Der);
const p12 = pkcs12.pkcs12FromAsn1(p12Asn1, password);
const certBags = p12.getBags({ bagType: forge.pki.oids.certBag });
const cert = certBags\[forge.pki.oids.certBag\]\[0\].cert;
const keyBags = p12.getBags({ bagType: forge.pki.oids.pkcs8ShroudedKeyBag });
const key = keyBags\[forge.pki.oids.pkcs8ShroudedKeyBag\]\[0\].key;
const signer = forge.pki.createSigner({
md: forge.md.sha256.create(),
rsaOptions: {
key: forge.pki.privateKeyToPem(key),
},
});
signer.certificates = \[cert\];
signer.update(text);
const signature = signer.sign();
console.log(signature);
'pfxData' is the binary data of the pfx file. 'password' is password of the pfx file. 'text' is the text to be signed. Which method should be used for signing?
