This guide explains how to generate a self-signed SSL certificate for local development or testing.
Ubuntu:
sudo apt update
sudo apt install opensslmacOS:
brew install opensslRun the following commands in this directory (backend/ssl):
# Generate a private key
openssl genrsa -out key.pem 2048
# Generate a certificate signing request (CSR)
openssl req -new -key key.pem -out csr.pem
# Generate a self-signed certificate (valid for ~27 years)
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
# Remove the CSR file (optional)
rm csr.pemYou will now have:
key.pem→ Your private keycert.pem→ Your self-signed certificate
Configure your application to use key.pem and cert.pem for HTTPS.
You can inspect your certificate using online tools like SSL Checker.
Note:
Browsers will show a warning for self-signed certificates. This is normal for development.
For production, always use a certificate from a trusted Certificate Authority (CA).
