Skip to content

Instantly share code, notes, and snippets.

@nlf
Created November 10, 2012 02:06
Show Gist options
  • Save nlf/4049524 to your computer and use it in GitHub Desktop.
Save nlf/4049524 to your computer and use it in GitHub Desktop.
simple multi-cert bouncy
var servers = {
'example.com': { port: 5000, key: fs.readFileSync('/path/to/key', 'utf8'), cert: fs.readFileSync('/path/to/cert', 'utf8') },
'example.net': { port: 6000, key: fs.readFileSync('/path/to/key2', 'utf8'), cert: fs.readFileSync('/path/to/cert2', 'utf8') }
}
function sni_check(servername) {
if (~Object.keys(servers).indexOf(servername)) {
return crypto.createCredentials(servers[servername]).context;
}
}
bouncy({ key: 'selfsigned.key', cert: 'selfsigned.crt', SNICallback: sni_check }, function (req, bounce) {
bounce(servers[req.headers.host].port);
}).listen(443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment