How to create a pem key in string format from base

2020-07-31 04:00发布

I'm trying to create a pem key from a ecdsa private key, I have to use a pem string in another function to create a JWT but when I'm trying

var base64key = 'MDc4M2UwODJiNmFhMmVmOWIxZDdjN2YwMTYxMGM4M2ZkZTk2OTE3OWVlNzdlYzBmNTJmY2NiNjBhMDBjNTA0OQ=='; var privKey64 = '-----BEGIN PRIVATE KEY-----\n'+base64key+'\n-----END PRIVATE KEY-----'; var sJWS = KJUR.jws.JWS.sign(null, {alg: "ES256"}, privKey64);

So when I'm trying to feed this pem key to sign function I'm getting following error

*init failed:malformed plain PKCS8 private key

So I suspect that the pem key generated is not of valid format

0条回答
登录 后发表回答