Skip to content

Instantly share code, notes, and snippets.

@billywhizz
Created May 16, 2011 23:51
Show Gist options
  • Save billywhizz/975620 to your computer and use it in GitHub Desktop.
Save billywhizz/975620 to your computer and use it in GitHub Desktop.
ssl test for node.js
/*
generate your key and cert as follows:
openssl genrsa -out server.key.pem 1024
openssl req -new -key server.key.pem -out server.csr.pem
openssl x509 -req -in server.csr.pem -signkey server.key.pem -out server.cert.pem
*/
var http = require("https");
var fs = require("fs");
var cred = {
key: fs.readFileSync("./server.key.pem"),
cert: fs.readFileSync("./server.cert.pem")
};
var httpd = http.createServer(cred, function(req, res) {
res.writeHead(200, {"Content-Type": "text/plain", "Content-Length": 0});
res.end();
});
httpd.listen(443, "0.0.0.0");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment