I don’t care if it is the OpenSSL, Python or other ways.
The reason why I want to convert from PKCS8 string (with Elliptic Curve key) to JSON Web Key (JWK), so I can see the claims like kid
, etc
I’ve tried using the eckles library.
var Eckles = require('eckles');
var pem = require('fs')
.readFileSync('./node_modles/eckles/fixtures/privkey-ec-p256.sec1.pem', 'ascii');
Eckles.import({ pem: pem }).then(function (jwk) {
console.log(jwk);
});
but the output only returns the kty, crv, d, x, y .. but not the kid
claims.
The kid is JWK specific, the PKCS#8 format does not contain a kid, which is why none is exported.
Incidentally, the conversion PEM->JWK is also possible with the crypto module of NodesJS:
crypto.createPrivateKey(<your PEM key>).export({format: 'jwk'})
.