(map reflect shtuff)
 => ramblings by Ahmad Nazir

Trust a self signed certificate in Debian

February 7, 2017

Generate a self-signed certificate

Generate a self-signed certificate in PEM format

DOMAIN=dev.penneo.com
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $DOMAIN.key -out $DOMAIN.crt

For a certificate that gets accepted by Chrome 68+, see the self signed certificate generator by Jesus Otero Gomez.

Trusting the certificate

For making the OS trust the certificate, the requirements for Debian are:

or in bash lingo:

CERTS=/etc/ssl/certs
sudo cp $DOMAIN.crt $CERTS/
cd $CERTS
HASH=`openssl x509 -noout -hash -in $DOMAIN.crt`.0
sudo ln -s $DOMAIN.crt $HASH

Source: Trusting self-signed certificates in redhat

You can check the details for the newly generated certificate as follows:

openssl x509 -in $DOMAIN.crt -text -noout

FAQ

Does this mean that the browsers also trust the certificate?

Some applications rely on the OS level trusted certificates. Browsers have a different way to established trust. For Chrome, you have to add the rootCA certificate instead of the self signed certificate. Check out Jesus’s self signed certificate generator to generate the rootCA.pem. Once you have that, it needs to be imported in Chrome:

Chrome Settings
  > Show advanced settings
  > HTTPS/SSL
  > Manage Certificates
  > Import certificate

What is PEM format?

PEM is a container format for storing certificates. There are a number of ways to store certificates and here is a quick reference for some extensions that I have bumped into: