- Public Key: Used for encrypting data. It can be shared openly.
- Private Key: Used for decrypting data. It must be kept secret.
In an encryption-decryption flow using RSA (asymmetric encryption), the roles of keys are divided between the client and server for security purposes:
- Used by the client to decrypt sensitive data sent to it by the server.
- Ensures only the client can decrypt data meant for it.
- Shared with the server.
- Used by the server to encrypt data that only the client can decrypt.
- Used by the server to decrypt sensitive data sent to it by the client.
- Ensures only the server can decrypt data meant for it.
- Shared with the client.
- Used by the client to encrypt data that only the server can decrypt.
Default encryption keys are stored in the project folder. If you want to generate your own keys, please use the instruction below to generate them and replace the existing ones.
- Install OpenSSL:
- Ubuntu/Debian
sudo apt install openssl # Ubuntu/Debian- macOS
brew install opensslWindows: Download it from OpenSSL.
- Generate Client Private Key:
openssl genrsa -out private.pem 2048- Generate Client Public Key:
openssl rsa -in private.pem -pubout -out public.pem- Generate Server Private Key:
openssl genrsa -out private.pem 2048- Generate Server Public Key:
openssl rsa -in private.pem -pubout -out public.pemOrganize and store the keys in the following directory structure within your project:
/api/keys/
├── client_rsa_keys/
│ ├── private.pem
│ ├── public.pem
├── server_rsa_keys/
├── private.pem
├── public.pem
- Store Client keys inside /api/keys/client_rsa_keys/
- Store Server keys inside /api/keys/server_rsa_keys/
- If the application is running, restart Docker