Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created June 29, 2012 20:37
Show Gist options
  • Save jfromaniello/3020495 to your computer and use it in GitHub Desktop.
Save jfromaniello/3020495 to your computer and use it in GitHub Desktop.
var https = require('https'),
path = require("path"),
fs = require("fs"),
crypto = require("crypto");
var certs = ["cer1", "cer2"].map(function(cer){
var r = crypto.createCredentials({
key: fs.readFileSync(path.join(__dirname, 'certs/' + cer + '.nopass.key')),
cert: fs.readFileSync(path.join(__dirname, 'certs/' + cer + '.crt'))
}).context;
r.name = cer;
return r;
});
var options = {
SNICallback: function(hostname){
// if ("lalalala.com" === hostname)
var cert = certs.shift();
console.log("using: " + cert.name);
certs.push(cert);
return cert;
}
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8002);
console.log("listening on 8002");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment