This guide will step you through the process of creating a self signed SSL certificate using the OpenSSL application. Sometimes you just need to test something using SSL, without the need to pay for a certificate from a trusted certificate authority. This will allow you to set up a SSL site on Apache, Nginx, or any other web server.
Create a SSL Private Key:
You will first need to create a private key that will be used to create the public certificate.
To create the private key, run the following command:
$ openssl genrsa 2048 > private.key
Set private.key to be a filename that is meaningful for you. Keep this file safe.
Create the self-signed SSL certificate from the private key:
Now we have the private key generated, you can create the self signed certificate.
To create the certificate file, run the following command:
$ openssl req -new -x509 -key private.key -out certificate.pem -days 365
Set the number of days you want the certificate to be valid for using the -days parameter.
You will be prompted for a number of options for the certificate. Fill these in as necessary. Set the “Common Name” to be the domain name the certificate will be used with.
The file “certificate.pem” will be the newly created self signed certificate file.
You can now take the private.key and certificate.pem files and set them up on your web server.