我可以使用win-ca和node-forge从证书中读取公钥。但是我无法从同一证书中读取私钥。
let ca = require('win-ca')
var forge = require('node-forge');
ca.each(ca.der2.x509, (certificate: any) => {
try {
if (certificate.subject.attributes[0].value === 'xyz') {
console.log(certificate.serialNumber);
var caCert = forge.pki.certificateFromPem(forge.pki.certificateToPem(certificate));
console.log(forge.pki.publicKeyToPem(caCert.publicKey));
}
}
catch (error) {
}
})