Skip to content

A PEM -> JWK command line conversion tool

License

Notifications You must be signed in to change notification settings

jphastings/jwker

Repository files navigation

Jwker

This is a command line tool to easily convert keys between the PEM and JWK file formats.

Usage

Convert from PEM to JWK format:

jwker my-key.pem my-key.jwk
jwker my-key.pem | pbcopy
cat my-key.pem | jwker > my-key.jwk

A complete example for creating a new keypair, saving the public key as a JWK and the private key as a PEM, but with a passphrase:

openssl ecparam -genkey -name prime256v1 \
| tee >(openssl ec -pubout | jwker > key.pub.jwk) \
| openssl ec -aes256 -out key.prv.pem

Convert from JWK to PEM format:

jwker my-key.jwk my-key.pwm
jwker my-key.jwk | pbcopy
cat my-key.jwk | jwker

Installation

If you have homebrew installed:

brew install jphastings/tools/jwker

Or, if you have go installed:

go install github.com/jphastings/jwker/cmd/jwker@latest