Created
June 29, 2012 20:37
-
-
Save jfromaniello/3020495 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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