A set of scripts to quickly generate a HTTPS certificate for your local development environment.
- Clone this repository and
cd
into it:
git clone https://github.com/dakshshah96/local-cert-generator.git
cd local-cert-generator
- Run the script to create a root certificate:
sh createRootCA.sh
- Trust this certificate after importing it to your System keychain:
- Run the script to create a domain certificate for
localhost
:
sh createSelfSigned.sh
- Move
server.key
andserver.crt
to an accessible location on your server and include them when starting it. In an Express app running on Node.js, you'd do something like this:
var path = require('path')
var fs = require('fs')
var express = require('express')
var https = require('https')
var certOptions = {
key: fs.readFileSync(path.resolve('build/cert/server.key')),
cert: fs.readFileSync(path.resolve('build/cert/server.crt'))
}
var app = express()
var server = https.createServer(certOptions, app).listen(443)