Knowledge Base


How to Install and Bind a Sectigo SSL Certificate on Node.js?
Product: Sectigo SSL Certificate
Platform: Node.js
Overview:
This guide provides the step-by-step process for installing a Sectigo SSL certificate on a Node.js server. Implementing SSL ensures secure communication between your server and clients by enabling HTTPS. To install a Sectigo SSL certificate in Node.js, you need to use the built-in https module and the fs module to read your certificate files and configure an HTTPS server. The core process involves obtaining your certificate files, placing them on your server, and updating your Node.js application code to use them.
Audience:
Developers or system administrators responsible for configuring SSL on Node.js applications.
Scope:
This procedure covers installing the SSL certificate files, configuring the Node.js HTTPS server, and verifying the installation.
Prerequisites
Before you begin, ensure you have the following files from Sectigo (typically provided via email or available for download from your account dashboard):
-
Your primary certificate file (yourDomainName.crt or similar)
-
The CA bundle file (yourDomainName.ca-bundle or similar), which contains intermediate and root certificates
-
Your private key file, which you generated when you created the Certificate Signing Request (CSR) (e.g., server.key or private.key). This file should be stored securely and never shared.
Step-by-Step Installation Guide
-
Upload the Certificate Files
-
Place all three files (primary certificate, CA bundle, and private key) in a secure directory on your server. A common practice is to place them in a dedicated SSL or certificates folder.
-
Create or Modify your Node.js Server File
-
You need to create a Node.js file for your HTTPS server, for example, https_server.js.
-
Inside this file, you will load the necessary modules and define the path to your certificate files.
(Use code with caution) Here is an example of the Node.js code:
var https = require('https');
var fs = require('fs');
// Define the options for the HTTPS server, specifying the paths to your files
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
};
// Create the HTTPS server
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');
Make sure to replace /path/to/ with the actual file paths on your server
-
Start the Node.js Application
-
Use your command line interface to start the Node.js application:
sudo node https_server.js
-
The SSL certificate is now active on your Node.js server.
Verification
-
To confirm the SSL installation:
-
Open a browser and navigate to https://yourdomainname.com.
-
Check the padlock icon in the address bar.
-
Optionally, use an online SSL checker to verify the certificate chain.
Related Articles:
Tags:
Need help?
Need help making a purchase? Contact us today to get your certificate issued right away.
Live chat
Click the button below or click "Chat with an Expert" to start chatting with us now!