generate own local ssl thanks to: https://stackoverflow.com/questions/21397809/create-a-trusted-self-signed-ssl-cert-for-localhost-for-use-with-express-node
15
Mkcert from @FiloSottile makes this process infinitely simpler:
- Install mkcert, there are instructions for macOS/Windows/Linux
mkcert -install
to create a local CAmkcert localhost 127.0.0.1 ::1
to create a trusted cert for localhost in the current directory- You're using node (which doesn't use the system root store), so you need to specify the CA explicitly in an environment variable, e.g:
export NODE_EXTRA_CA_CERTS="$(mkcert -CAROOT)/rootCA.pem"
- Finally run your express server using the setup described in various other answers (e.g. below)
- boom. localhost's swimming in green.
Basic node setup:
const https = require('https');
const fs = require('fs');
const express = require('express');
const app = express();
const server = https.createServer({
key: fs.readFileSync('/XXX/localhost+2-key.pem'), // where's me key?
cert: fs.readFileSync('/XXX/localhost+2.pem'), // where's me cert?
requestCert: false,
rejectUnauthorized: false,
}, app).listen(10443); // get creative
Comments
Post a Comment