I have a p12 file containing the private key to be used to sign my OAuth requests. But, the OAuth NodeJS lib (ciaranj/node-oauth) doesn't take this format as input.
I tried many OpenSsl options (PKCS#8 or traditional PEM format) to extract my private key from the PKCS#12 keystore, but I can't get the OAuth header signature to get accepted.
What OpenSsl options shall I use to create a PEM file usable as follows:
var privateKey = fs.readFileSync("privateKey.pem").toString('ascii');
var oauth= new OAuth(null, null, consumerKey, privateKey, "1.0", null, "RSA-SHA1");
I'm not an OpenSsl expert so any hint would be very welcomed.
PS: Alternatively, as the OAuth lib uses the sign API of NodeJS crypto, if you know a way to use a PKCS#12 file for signing, this could save me.
After many attempts, I found a solution. So, I thought I'd share the commands here if it can be useful for someone else: This extract the private key from the PKCS#12 file:
openssl pkcs12 -in myKeystore.p12 -nocerts -out privateKeyPkcs8.pem
But the outcome is PKCS#8 encoded which isn't what NodeJS crypto package expects. So, I had to run the following command to get the traditional PEM encoding:
openssl pkcs8 -in privateKeyPkcs8.pem -out privateKey.pem