Technical Documents & Guides

How to Install Certificates on Node.js in Linux

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

<pre>var https = require('https');<br>var fs = require('fs');</pre>

var https_options = {
 ca: fs.readFileSync("/path/to/"),
 key: fs.readFileSync("/path/to/server.key"),
 cert: fs.readFileSync("/path/to/mydomain.crt")
https.createServer(options, function (req, res) {
 res.end("Welcome to Node.js HTTPS Servern");

2. Now use the following command to start node.js application created in above step.

# node https_server.js

Chat With Us

We are here for you!
Talk to a fellow human.

United States