SSL certificates in dev & test environmentsΒΆ
In simplest cases and for simplest projects, we don't bother with SSL certificates... until we start to work with some feature that won't work without it like WebRTC or PWA. Same thing if you want to start working with third party APIs.
Generating self-signed certificate quickly becomes mandatory, and managing them between several projects can be challenging if you don't do it properly...
Have you ever heard about Root Certificates? It makes our lives better
This tutorial is easy and quick to follow, but it assumes that you're generating your certificates in a Linux environment. Please adapt your OpenSSL usage if you work on another system.
Generating a Root CertificateΒΆ
We'll work with OpenSSL.
To keep things tidy, we save each certificate in the same folder ~/SSLConfig
:
Now, you'll be able to generate as many certificates as you want, and you will just have to add your CA.crt
to trusted CA lists to any device/browser
you want to be able to access to your services.
Installing the root certificate in ubuntu
Generating a certificateΒΆ
Since we generated a root certificate, let's create our SSL certificate for our demo.dev.local
website :
Then, let's create an ext
file used to create our certificate :
demo.dev.local.ext | |
---|---|
Note
The last line allow you to use your SSL certificate when querying https://192.168.1.14
.
As such, it's optional.
Then run the following commands to generate all required files :
Danger
When generating your certificates, you will be printed some questions about certificate (Common Name, Organization info, email, etc.).
The CN (Common Name) must be UNIQUE for EACH certificate, including the root CA.
If not, NodeJS will reject your certificates and mark them as self-signed
as described here.
Now, you should have this folder structure :
Configuring the apache2 proxy with our certificate
To be able to use any of your certificates in a browser, you must install the root certificate into your browser / system / smartphone, and all the generated certificates signed with this CA will be trusted too.
Didn't I tell you that Root Certificates are our best friends?