I was trying to point two independent domain to my node.js server. Everything woks well but HTTPS. I realized my only option for having two separated HTTPS address on a single web server is using SNI but I couldn't make it work in my node server. Here is a simple example of what I'm trying to do:
'use strict';
var crypto = require('crypto');
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('ssl/server.key'),
passphrase: 'something',
cert: fs.readFileSync('ssl/xxx.crt'),
ca: fs.readFileSync('ssl/ca.crt'),
// Dynamic certificate check
SNICallback: function (servername) {
console.log('sni:', servername); // This function is never called
}
};
https.createServer(options, function (req, res) {
req.on('end', function () {
res.writeHead(200, {'Content-Type':'application/json'});
res.end('{}');
});
}).listen(443);
I know SNI in not supported by all browsers and it only works with TLS, but I tested it with Chrome 36, Firefox 30 and IE 10.
I also tested changing secureProtocol to 'TLSv1_method' and 'SSLv3_method' but it didn't work too.
Is there anyway to make it work? Is there any other solution that does not require SNI? It's not related to node but I know there is a gnutls_certificate_set_retrieve_function2 function in GNU for that.