Before configuring the SSL with node.js, please ensure that you have your 'Private Key', 'Certificate' and 'Intermediate(s)' certificates. You might have received the following certificates from Sectigo.
1) your_domain_name.crt (or) OrderNumber.crt - It is your Server Certificate
2) Intermediate Certificates, it depends upon the type of Certificate you purchase. Mostly, you will get them in the following format.
Ex: 'SectigoRSAXXXXXXXXXSecureServerCA.crt' and 'USERTrustRSAAddTrustCA.crt'
Note: You may have received a .ca-bundle file, which includes those Intermediate Certificates. In this case, please download the appropriate certificate from Downloads.
1. Create an https_server.js file using the following values. you can create file with any name using .js extension.
# 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: [
fs.readFileSync('path/to/SectigoRSAXXXXXXXXXSecureServerCA.crt'),
fs.readFileSync('path/to/USERTrustRSAAddTrustCA.crt')
]
};
https.createServer(options, function (req, res) { res.writeHead(200); res.end('Welcome to Node.js HTTPS Servern'); }).listen(8443)
2. Now use the following command to start node.js application created in above step.
# node https_server.js
3. To verify the installation, you can use Qualys SSL Server Test.