Skip to content

Instantly share code, notes, and snippets.

@alvarow
Created April 8, 2016 20:48
Show Gist options
  • Save alvarow/0377eb3ffec534428135eec1ea80ba9f to your computer and use it in GitHub Desktop.
Save alvarow/0377eb3ffec534428135eec1ea80ba9f to your computer and use it in GitHub Desktop.
node.js https server example
// curl -k https://localhost:8000/
const https = require('https');
const fs = require('fs');
const options = {
passphrase: '1234',
dhparam: fs.readFileSync('dhparam.pem'),
key: fs.readFileSync('cert.key'),
cert: fs.readFileSync('cert.pem'),
ca: fs.readFileSync('ca.pem')
};
https.createServer(options, (req, res) => {
res.writeHead(200);
res.end('hello world\n');
}).listen(8443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment