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
|
2020-07-28 21:53:50 +00:00
|
|
|
.createSecureServer({ SNICallback: SNICallback }, function (req, res) {
|
2019-10-27 06:55:40 +00:00
|
|
|
res.end('Hello, Encrypted World!');
|
|
|
|
})
|
2020-07-28 21:53:50 +00:00
|
|
|
.listen(443, function () {
|
2019-10-27 06:55:40 +00:00
|
|
|
console.info('Listening on', server.address());
|
|
|
|
});
|