Habilelabs-Logo
Blog

How to create a Self-Signed SSL Certificate

March 31st, 2017 . 2 minutes read
Blog featured image

Prerequisites to create Self-Signed SSL Certificate:

For creating self-signed SSL certificate you first need to be sure that OpenSSL is installed on your computer, generally, it’s coming installed in windows 10 nowadays, you can check this by-

1.open cmd a nd type
$ which OpenSSL

If this command return address like this /usr/bin/openssl means you are ready otherwise you need to install it first.
for Windows- >http://gnuwin32.sourceforge.net/packages/openssl.htm

Now, before creating final SSL certificate you first need to build private key and certificate signing request. See, this step is essential for creating SSL certificate. You just have to type some simple commands-

openssl genrsa -des3 -passout pass:x -out localhost.pass.key 2048

$ openssl rsa -passin pass:x -in localhost.pass.key -out localhost.key
writing RSA key
$ rm localhost.pass.key
$ openssl req -new -key localhost.key -out localhost.csr

After this, it will ask for some few entries for your signing request, just fill it normally like-

country
city
password
name
company
etc.

You can skip password there is no need of, this is used when you buy an SSL certificate but remember name filed it must be same as type your key name like here it is localhost- 

Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:California

A challenge password []:

now you are one command away from your SSL certificate, write
$ OpenSSL x509 -req -sha256 -days 365 -in localhost.CSR -signkey localhost.key -out localhost.crt

Here it is localhost.crt

Now, include this files in your server.js-

Now add this localhost.crt file in your browser to make it trust the certificate.
Go to setting ->manage certificate ->import
Refresh the browser and enjoy.

Ask if you have any problem in Creating Self-Signed SSL Certificate, ask in comment box.

Share this with your friends if you found this helpful.

Author: rahul
Share: