From e725bea1d2e91951c1a94f43c291fc1fb40afea3 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Mon, 15 Oct 2018 13:26:03 +0200 Subject: [PATCH] Update docs for RSA signing/verification --- README.md | 4 +++- tests/notes.md | 22 ---------------------- tests/public_rsa_key_8.pem | 8 ++++++++ 3 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 tests/notes.md create mode 100644 tests/public_rsa_key_8.pem diff --git a/README.md b/README.md index c4dedbe..32e21ff 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,9 @@ This library currently supports the following: ### RSA `jsonwebtoken` can only read DER encoded keys currently. If you have openssl installed, -you can run the following commands to obtain the DER keys from .pem: +you can run the following commands to obtain the DER keys from PKCS#1 (ie with `BEGIN RSA PUBLIC KEY`) .pem. +If you have a PKCS#8 pem file (ie starting with `BEGIN PUBLIC KEY`), you will need to first convert it to PKCS#1: +`openssl rsa -pubin -in -RSAPublicKey_out -out `. ```bash // private key diff --git a/tests/notes.md b/tests/notes.md deleted file mode 100644 index 41680ba..0000000 --- a/tests/notes.md +++ /dev/null @@ -1,22 +0,0 @@ -# Generating RSA keys - -Using `openssl` - -## PEM -`openssl genrsa -out private_rsa_key.pem 2048` - -Getting public key: -`openssl rsa -in private_rsa_key.pem -outform PEM -pubout -out public_rsa_key.pem` - -## DER -Same as PEM but replace `PEM` by `DER`. -`openssl rsa -in private_rsa_key.pem -outform DER -pubout -out public_rsa_key.der` - -## Converting private PEM to DER -`openssl rsa -in private_rsa_key.pem -outform DER -out private_rsa_key.der` - -## Converting private DER to PEM -`openssl rsa -in private_rsa_key.der -inform DER -outform PEM -out private_rsa_key.pem` - -## Generating public key -`openssl rsa -in private_rsa_key.der -inform DER -RSAPublicKey_out -outform DER -out public_key.der` diff --git a/tests/public_rsa_key_8.pem b/tests/public_rsa_key_8.pem new file mode 100644 index 0000000..99e2a40 --- /dev/null +++ b/tests/public_rsa_key_8.pem @@ -0,0 +1,8 @@ +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEAyRE6rHuNR0QbHO3H3Kt2pOKGVhQqGZXInOduQNxXzuKlvQTLUTv4 +l4sggh5/CYYi/cvI+SXVT9kPWSKXxJXBXd/4LkvcPuUakBoAkfh+eiFVMh2VrUyW +yj3MFl0HTVF9KwRXLAcwkREiS3npThHRyIxuy0ZMeZfxVL5arMhw1SRELB8HoGfG +/AtH89BIE9jDBHZ9dLelK9a184zAf8LwoPLxvJb3Il5nncqPcSfKDDodMFBIMc4l +QzDKL5gvmiXLXB1AGLm8KBjfE8s3L5xqi+yUod+j8MtvIj812dkS4QMiRVN/by2h +3ZY8LYVGrqZXZTcgn2ujn8uKjXLZVD5TdQIDAQAB +-----END RSA PUBLIC KEY-----