In this article, you will find out how to install an SSL Certificate on Node.js. The SSL configuration requires all the certificate files including root, intermediate, and primary certificates. You should have these files in an archived folder received from your Certificate Authority.

If you haven’t applied for an SSL Certificate yet, the first part of this guide explains how to generate a CSR code for Node.js. This step is necessary since the CSR (Certificate Signing Request) contains your contact details.

After the installation, continue reading to discover interesting facts about Node.js history, as well as the best place online where you can get an SSL certificate for your Node.js platform.

Generate a CSR code in Node.js
Install an SSL Certificate on Node.js
Node.js history and versions
Where to buy an SSL Certificate for Node.js?

Generate a CSR code in Node.js

To generate the CSR, we’re going to use the OpenSSL utility. Usually, OpenSSL should be available on your server, but if it’s not, you can download it.

Alternatively, you can get OpenSSL via the following commands:

  • sudo apt-get install openssl
  • sudo yum install openssl
  1. Run the following command to start the CSR generation process:
    openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
  2. Replace yourdomain with the domain name you want to secure
    • Yourdomain.key is your private key
    •  Yourdomain.csr is your CSR code
  3. Next, provide the required details. Please fill in the fields as below:
    • Common name: specify the FQDN (fully qualified domain name) to which you want to assign your SSL Certificate (ex: If you bought a Wildcard Certificate, include an asterisk in front of the domain name (ex: *
    • City: enter the city where your business is officially registered (ex: San Jose)
    • State: enter the state where your company is located (ex: California)
    • Country: enter the two-letter country code of your organization (ex: US)
    • Organization: type the official, full name of your organization (ex: GPI Holding LLC). For Domain Validation (DV) Certificates, type NA instead
    • Organizational Unit: specify the unit responsible for SSL management (ex: IT or Web Administration). If you have a DV certificate, put it NA instead
    • Email Address: this is an optional field. You can leave it blank
    • Challenge Password: another optional field. We recommend leaving this field bank because challenge password is an obsolete attribute
  4. Your CSR Code is ready to use. By default, it resides in yourdomain,csr. You can open it with any text editor such as Notepad. When applying for your certificate, please include the full CSR text including the —-BEGIN CERTIFICATE REQUEST—– and —–END CERTIFICATE REQUEST—– tags
  5. Along with the CSR, the OpenSSL utility will also create your private key (yourdomain.key). Save and store it in a safe place. You will need it during the SSL configuration.

Install an SSL Certificate on Node.js

  1. Prepare all your certificate files. Here’s what you’re going to need:
    • The primary certificate for your domain (.crt extension)
    • The root certificate (.crt)
    • The Ca Bundle file containing the root and intermediate certificates. (.ca-bundle extension)
    • Your private key generated along with CSR (.key extension)
  2. Create an HTTPS server in Node.js environment. In the command line, use the following values to create your HTTPS server. For this demonstration, we’ve named it https_server.js, but you can give any name to the server.js file
    #vim https_server.js
    var https = require('https');
    var fs = require('fs');
    var https_options = {
    key: fs.readFileSync("/path/to/private.key"),
    cert: fs.readFileSync("/path/to/your_domain_name.crt"),
    ca: [
    https.createServer(options, function (req, res) {
    res.end("Welcome to Node.js HTTPS Servern");
  3. You need to replace the parts in bold with your corresponding information.
    • path/to/private.key – indicate the full path to your private key file
    • path/to/your_domain_name.crt – specify the correct path to your SSL certificate file
    • path/to/CA_root.crt’ – type the full path of the CA root certificate file
    • path/to/ca_bundle_certificate – enter the full path of to your CA bundle file
  4. Activate your SSL Certificate on Node.js. Run the following command to launch the Node.js app: # node https_server.js
  5. Test your SSL installation for potential errors or vulnerabilities using one of these SSL checker tools.

Node.js history and versions

Node.js is a free open-source server environment that runs on various platforms including Linux, Unix, Windows, Mac OS X and executes JavaScript code outside of a browser. The original author of Node.js is Ryan Dahl, an American software engineer.

Dahl’s inspiration to create Node.js came up after seeing a file upload progress bar on Flickr. Initially, Dahl named its project Web.js because it was just an alternative for Apache. Later, when the project grew beyond the server library into a versatile framework, Dhal renamed it Node.js.

Below you’ll find the latest Node.js releases, still receiving support.

  • 6.x (Boron) – released in 2016, it is currently at the end of the long-term support, with maintenance ending in April 2019
  • 8.x (Carbon) – released in 2017, it has active support until April 2019, and maintenance support until December 2019
  • 10.x (Dubnium) – released in 2018, it has active support until April 2020, and maintenance support until April 2021.

Where to buy an SSL Certificate for Node.js?

The best place to buy an SSL Certificate for Node.js is from SSL Dragon. We offer amazing prices, regular discounts and unbeatable deals on the entire range of our SSL products. We’ve carefully selected the best SSL brands on the market to equip your website with high-end encryption. All our SSL certificates are compatible with Node.js. Here are the types of SSL certificates we sell:

To help you select the ideal SSL certificate, we created a couple of exclusive SSL tools. Our SSL Wizard does the SSL searching for you and recommends the best SSL deal for your online project. On the other hand, the Advanced Certificate Filter sorts and compares different SSL certificates by price, validation, and features, so you have the complete picture when making the final decision.

If you find any inaccuracies, or you have details to add to these SSL installation instructions, please feel free to send us your feedback at [email protected]. Your input would be greatly appreciated! Thank you.