Knowledge Base

How to Install and Bind a Sectigo SSL Certificate on Node.js

 
 

Overview 

By the end of this article, you will have a Node.js server that serves traffic over HTTPS using your Sectigo SSL certificate. The article covers, in order: gathering your certificate files from the Certificate Authority (CA), uploading them to your server, configuring a Node.js HTTPS server with the built-in https and fs modules, and verifying the installation. Your certificate files are the primary certificate, the CA bundle (the intermediate and root certificates that let browsers trust your certificate), and the private key you generated with your Certificate Signing Request (CSR). 

Prerequisites 

Before you begin, obtain the following files from Sectigo (sent by email or available in your account dashboard): 

  • Your primary certificate file (for example, yourDomainName.crt) 

  • The CA bundle file (for example, yourDomainName.ca-bundle), which contains the intermediate and root certificates 

  • Your private key file (for example, server.key or private.key), generated when you created the Certificate Signing Request (CSR). Store this file securely and never share it. 

Steps 

Step 1 — Upload the certificate files 

Place all three files (the primary certificate, the CA bundle, and the private key) in a secure directory on your server, such as a dedicated /ssl or /certificates folder. 

Step 2 — Create or modify your Node.js server file 

Create a Node.js file for your HTTPS server, for example https_server.js. In this file, load the https and fs modules and point each option to the matching certificate file: 

var https = require('https'); 
var fs = require('fs'); 
 
var options = { 
  key: fs.readFileSync('/path/to/private.key'),      // Your private key 
  cert: fs.readFileSync('/path/to/certificate.crt'),  // Your primary certificate 
  ca: fs.readFileSync('/path/to/bundle.ca-bundle')    // Your CA bundle 
}; 
 
https.createServer(options, function (req, res) { 
  res.writeHead(200); 
  res.end("Welcome to Node.js HTTPS Server!\n"); 
}).listen(443); // Listen on the standard HTTPS port (443) 
 
console.log('HTTPS server running on port 443'); 

Replace /path/to/ with the actual file paths on your server. 

Step 3 — Start the Node.js application 

From your command line, start the application: 

sudo node https_server.js 

 

      Fig 1: Example image of starting the application from command line 

 

The SSL certificate is now active on your Node.js server. 

How to verify success 

The installation is successful when your site loads over HTTPS without browser warnings. Open a browser, navigate to https://yourdomainname.com, and confirm the padlock icon appears in the address bar. Optionally, use an online SSL checker to confirm the certificate chain is complete. 

Troubleshooting 

Issue: The server fails to start with a permission error on port 443. 

Cause: Ports below 1024 require elevated privileges. 

Solution: Start the application with sudo, or run Node.js behind a reverse proxy that binds to port 443. 

Issue: The server fails to start with a file path or “no such file” error. 

Cause: One of the key, cert, or ca paths does not match the uploaded files. 

Solution: Confirm each path in the options object points to the actual file location from Step 1. 

 
  •  

Need assistance?

Contact our team for help with your purchase or issuing your certificate.

Live chat

Call us today