const { getPem } = require('google-p12-pem');
/**
* Given a p12 file, convert it to the PEM format.
* @param {string} pathToCert The relative path to a p12 file.
*/
async function quickstart() {
// TODO(developer): provide the path to your cert
const pathToCert = '/MYPATH/GOOGLE_P12_PATH.p12';
const pem = await getPem(pathToCert);
console.log('The converted PEM:');
console.log(pem);
}
quickstart();
Error:
MYPATH/test/node_modules/node-forge/lib/rsa.js:1434
_bnToBytes(key.n)),
^
TypeError: Cannot read properties of undefined (reading 'n')
at pki.privateKeyToAsn1.pki.privateKeyToRSAPrivateKey (MYPATH/test/node_modules/node-forge/lib/rsa.js:1434:22)
at pki.privateKeyToPem (MYPATH/test/node_modules/node-forge/lib/pki.js:82:26)
at convertToPem (MYPATH/test/node_modules/google-p12-pem/build/src/index.js:42:31)
at MYPATH/test/node_modules/google-p12-pem/build/src/index.js:27:16
at async quickstart (MYPATH/test/index.js:11:15)
Environment details
google-p12-pem
version: ^5.0.0Steps to reproduce
Error:
Inside node_modules/google-p12-pem/build/src/index.js:
If I change the following:
to:
Things work as expected. How do I deal with this? Is there a reason for using first key and not the second? Why is it hard coded?