From 7a04445a224312948ec34820b9fbc5a786d16c66 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 18 Apr 2024 21:01:14 +0300 Subject: gn-auth: doc: Generating key-pairs --- topics/gn-auth/generating-key-pairs.gmi | 85 +++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 topics/gn-auth/generating-key-pairs.gmi diff --git a/topics/gn-auth/generating-key-pairs.gmi b/topics/gn-auth/generating-key-pairs.gmi new file mode 100644 index 0000000..9fbcaa9 --- /dev/null +++ b/topics/gn-auth/generating-key-pairs.gmi @@ -0,0 +1,85 @@ +# Generating Key-Pairs + +## Tags + +* type: documentation +* keywords: doc, documentation, gn-auth, key-pair, jwt + +## Generating the Key-Pair + +If openssl is not present on your system, you need to get it. You can either install it with your package manager, or if you are using GNU Guix, you can do something like: + +``` +$ guix shell --container --network --share= openssl +``` + +where is where you will store the key-pairs. + +Now we can generate a private key (2048-bit RSA key) with: + +``` +[env] $ openssl genrsa -out /private.pem 2048 +``` + +and the public key with: + +``` +[env] $ openssl rsa \ + -in /private.pem \ + -outform PEM \ + -pubout \ + -out /public.pem +``` + +**NOTE**: You can store the public key separately from the private key. In that case, you'd have to have something like: + +``` +$ guix shell --container --network \ + --share= \ + --share= \ + openssl +``` + +and run the generation commands above with the appropriate directories in mind. + +## Configuring Services + +Now we need to configure the various services to make use of the key-pair. + +For the client services (GN2, gn-uploader, etc), we only need to give access to the public key, so we can do: + +``` +# gn2.conf +︙ +SSL_KEY_PAIR_PUBLIC_KEY = "/public.pem" +︙ +``` + +For the authorisation server (gn-auth), we need both: + +``` +# gn-auth.conf +SSL_KEY_PAIR_PUBLIC_KEY = "/public.pem" +SSL_KEY_PAIR_PRIVATE_KEY = "/private.pem" +``` + +## Exposing the Key-Pairs to Guix shell/container + +The generated keys above do not need to be modified within the running application, so we will use the "--expose" option e.g. + +``` +$ guix system container \ + ︙ + --expose= \ + ︙ +``` + +or if you stored the keys separately: + +``` +$ guix system container \ + ︙ + --expose= \ + --expose= \ + ︙ +``` -- cgit v1.2.3