I have this in Node.js:
const http2 = require('http2')
const fs = require('fs')
let server
start({
port: process.env.PORT || 3000,
private: fs.readFileSync('/Users/me/certs/localhost.key').toString(),
public: fs.readFileSync('/Users/me/certs/localhost.crt').toString()
})
async function start(opts) {
server = await createServer(opts)
}
async function createServer({ port, private, public, password }) {
return new Promise((res, rej) => {
let server = http2.createSecureServer({
key: private,
cert: public,
passphrase: password,
allowHTTP1: true,
secureProtocol: 'TLSv1_2_method'
}, handleServerRequest)
server.listen(port, fault => {
if (fault) {
rej(fault)
} else {
res()
}
})
})
}
async function handleServerRequest(req, res) {
console.log('here')
}
I generated my certs (and I think added it to the trust store on my computer) like this:
mkdir ~/certs
cd ~/certs
openssl req -x509 -sha256 -nodes \
-subj '/CN=localhost' \
-newkey rsa:2048 -days 365 \
-keyout localhost.key -out localhost.crt
open localhost.crt # add it to something? login?
sudo security add-trusted-cert \
-p ssl -d -r trustRoot \
-k ~/Library/Keychains/login.keychain localhost.crt
However, upon running the Node.js server and visiting https://localhost:3000, I get this:
What am I doing wrong? How do I fix it?
