JOIN OUR AFFILIATE NETWORK

Join our affiliate network and become a local SSL expert

♦ learn more about our program ♦
Menu
picture of tbs certificates
picture of tbs certificates
Certificates
Our products range
Partners
Support
Focus


Installing a certificate on Node.js

To install a certificate on Node.js, you must first go to the certificate status page (link available in the delivery email). Click on the "View Certificate" button and in the window that appears, retrieve:

  • your certificate: click on the link starting with "cert-XXXXXXXX" to download your certificate.
  • the certification chain: click on "View certification chain" and then click on the TXT file starting with "chain-XXXXXXXX".
  • the root certificate: click on "View root certificate" and click on the file starting with "rootCert-XXXXXXXX".

Once these three files have been downloaded, make them available on your server along with your private key that you generated when you ordered the certificate.
Then create a configuration file for node.js. For example with this command :

    #vim https_server.js // Note: you can choose another filename if you wish

In this file, here are the parameters to be entered :

    var https = require('https');
    var fs = require('fs');
    var https_options = {

    key: fs.readFileSync("/path/to/privatekey.key"),

    cert: fs.readFileSync("/path/to/cert-XXXXXXXXXX.cer"),

    ca: [

          fs.readFileSync('/path/to/rootCert-XXXXXXXXXX.cer'),

          fs.readFileSync('/path/to/chain-XXXXXXXXXX.txt')

       ]
    };

    https.createServer(options, function (req, res) {

        res.writeHead(200);
    
        res.end("Welcome");

    }).listen(8443)

All you have to do is start Node.js with the command :

    # node https_server.js

Useful links