Table of Contents
Creating certificate files
- Navigate to desired location where the certificate will be created (for example
$ mkdir local-ssh-certificates;cd local-ssh-certificates) - Install mkcert tool:
$ brew install mkcert - Generate certificates for
localhost:$ mkcert localhost - Install local CA in the system thrust store (this does not work for Firefox)
mkcert -install
Setting up Express server to use certificates
Make sure to replace /Users/toni/local-ssh-certificates with your real location.
var express = require('express');
var https = require('https');
var app = express();
const path = require('path');
const fs = require('fs');
app.use(express.static('src'))
https.createServer({
// replace with certificate location
key: fs.readFileSync('/Users/toni/local-ssh-certificates/localhost-key.pem'),
cert: fs.readFileSync('/Users/toni/local-ssh-certificates/localhost.pem')
}, app).listen(5001);
console.log('App listening on port 5001!');