How to create a pem key in string format from base64 encoded key
Asked Answered
T

0

1

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

Transfer answered 16/12, 2015 at 14:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.