In this tutorial, we will be using the OpenSSL library.
OpenSSL is a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library.
openssl – Used to call the library.
For Node.JS you can install OpenSSL with the below command line…
npm install openssl
Step 1.) Log in to the server through SSH from your computer.
- Mac OSX – ‘Terminal’.
- Windows – ‘Putty‘.
Step 2.) Create a .KEY & .CSR certificate
openssl req -nodes -newkey rsa:2048 -keyout systemctrl.com.key -out systemctrl.csr<br />
openssl req -nodes -newkey rsa:2048 -keyout ssl/server.key -out ssl/website.com.csr -subj "/C=NV/ST=Nevada/L=Las Vegas/O=website.co/OU=systemctrl.com/CN=website.<br />
Let’s break down each tag.
req – The req command primarily creates and processes certificate requests in PKCS#10 format. It can additionally create self-signed certificates for use as root CAs for example.
-nodes – If this option is specified then if a private key is created it will not be encrypted.
-newkey – option. The smallest accepted key size is 512 bits. If no key size is specified then 2048 bits is used.
-keyout – This is the default filename to write a private key to. If not specified the key is written to standard output.
-out – This specifies the output filename to write to or standard output by default.
-subj – Prints out the request subject (or certificate subject if -x509 is specified)
C= Country Name (2 letter code)
ST= State Name
L= Locality Name (City)
O= Organizational Unit Name (Legal Name of Business)
CN= Common Name (Website URL)