Enabling a node.js SSL webserver using Let’s Encrypt .pem certificates

In this article I will show a simple example of getting a node.js SSL website up and running using the .pem certificates issued from Let’s Encrypt.



Once you have gone through the process of getting your Let’s Encrypt certificates you will have 4 certificates


You will need to download the root certificate and an intermediate certificate from Let’s Encrypt – https://letsencrypt.org/certificates/


Once you have the root.pem the actual node code to get this running is relatively simple.


// Startup Express App
var express = require('express');

var https = require('https');
var http = require('http');
var fs = require('fs');
var app = express();

var options = {
  key: fs.readFileSync('copperCerts/privkey1.pem'),
  cert: fs.readFileSync('copperCerts/cert1.pem'),
  ca: [
    fs.readFileSync('copperCerts/root.pem', 'utf8'),
    fs.readFileSync('copperCerts/chain.pem', 'utf8')

https.createServer(options, app).listen(3000);