Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@AstraLuma
Created February 19, 2012 18:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AstraLuma/1865021 to your computer and use it in GitHub Desktop.
Save AstraLuma/1865021 to your computer and use it in GitHub Desktop.
HTTPS Test Server
#!/usr/bin/env node
const fs = require("fs"),
https = require("https");
var opts = {
key: fs.readFileSync("myprivatekey.pem", 'utf8'),
cert: fs.readFileSync("mypublickey.pem", 'utf8'),
ca: [fs.readFileSync("ca-pub.pem", 'utf8')],
requestCert: true,
rejectUnauthorized: true
};
var handler = function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
};
var server = https.createServer(opts, handler);
server.listen(443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment