node.js - How to extract the private key from a PKCS#12 file for further use with nodeJS OAuth -


i have p12 file containing private key used sign oauth requests. but, oauth nodejs lib (ciaranj/node-oauth) doesn't take format input.

i tried many openssl options (pkcs#8 or traditional pem format) extract private key pkcs#12 keystore, can't oauth header signature accepted.

what openssl options shall use create pem file usable 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 openssl expert hint welcomed.

ps: alternatively, oauth lib uses sign api of nodejs crypto, if know way use pkcs#12 file signing, save me.

after many attempts, found solution. so, thought i'd share commands here if can useful else: extract private key pkcs#12 file:

openssl pkcs12 -in mykeystore.p12 -nocerts -out privatekeypkcs8.pem 

but outcome pkcs#8 encoded isn't nodejs crypto package expects. so, had run following command traditional pem encoding:

openssl pkcs8 -in privatekeypkcs8.pem -out privatekey.pem 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -