var forge = require('node-forge');
//some code here
var keyFile = fs.readFileSync('./test.p12', 'binary');
var p12Asn1 = forge.asn1.fromDer(keyFile);
var p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1,false, employeeID);
var bags = p12.getBags({bagType: forge.pki.oids.certBag});
var cert = bags[forge.pki.oids.certBag][0];
var msg = {
type: 'CERTIFICATE',
body: forge.asn1.toDer(asn1.cert).getBytes()
};
var pem = forge.pem.encode(msg);
我正在尝试从p12文件中读取证书,RSA私钥和发布密钥。这是我在Node js中编写的代码,但是获得了TypeError。