# 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. The private key should only be accessible from the client (e.g. GN2, gn-uploader, etc.). In that respect, we can, for example have the following example config for GN2 ``` # gn2.conf ︙ SSL_KEY_PAIR_PRIVATE_KEY = "/private.pem" SSL_KEY_PAIR_PUBLIC_KEY = "/public.pem" ︙ ``` The authorisation server (gn-auth), only needs access to the public keys for the various clients. As such, we could have something like: ``` # gn-auth.conf SSL_KEY_PAIR_PRIVATE_KEY = "" ``` The directory should be writable for the authorisation server, since each client that will be registered will need to provide its own public key. ## 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= \ ︙ ``` To make this easy, and since each client can (and should) have a different private key, we can put these keys in the same directory as the secrets, and simply allow access to that. Each service within the guix container can then have access to the relevant key(s) as appropriate.