acme.js/examples/https-sni-server.js

22 lines
530 B
JavaScript
Raw Normal View History

2019-10-27 06:55:40 +00:00
'use strict';
var https = require('http2');
var tls = require('tls');
var fs = require('fs');
var key = fs.readFileSync('./privkey.pem');
var cert = fs.readFileSync('./fullchain.pem');
function SNICallback(servername, cb) {
console.log('sni:', servername);
cb(null, tls.createSecureContext({ key, cert }));
}
var server = https
.createSecureServer({ SNICallback: SNICallback }, function(req, res) {
res.end('Hello, Encrypted World!');
})
.listen(443, function() {
console.info('Listening on', server.address());
});