I'm adding HTTPS support to an embedded Linux device. I have tried to generate a self-signed certificate with these steps:
openssl req -new > cert.csr
openssl rsa -in privkey.pem -out key.pem
openssl x509 -in cert.csr -out cert.pem -req -signkey key.pem -days 1001
cat key.pem>>cert.pem
This works, but I get some errors with, for example, Google Chrome:
This is probably not the site you are looking for!
The site's security certificate is not trusted!
Am I missing something? Is this the correct way to build a self-signed certificate?
This is the script I use on local boxes to set the SAN (subjectAltName) in self-signed certificates.
This script takes the domain name (example.com) and generates the SAN for *.example.com and example.com in the same certificate. The sections below are commented. Name the script (e.g.
generate-ssl.sh
) and give it executable permissions. The files will be written to the same directory as the script.Chrome 58 an onward requires SAN to be set in self-signed certificates.
This script also writes an information file, so you can inspect the new certificate and verify the SAN is set properly.
If you are using Apache, then you can reference the above certificate in your configuration file like so:
Remember to restart your Apache (or Nginx, or IIS) server for the new certificate to take effect.