2014-07-15 03:20:49 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var https = require('https')
|
2014-07-15 03:38:33 +00:00
|
|
|
, port = process.argv[2] || 8043
|
2014-07-15 03:20:49 +00:00
|
|
|
, fs = require('fs')
|
|
|
|
, path = require('path')
|
|
|
|
, server
|
|
|
|
, options
|
|
|
|
;
|
|
|
|
|
|
|
|
require('ssl-root-cas')
|
|
|
|
.inject()
|
2014-07-16 04:54:02 +00:00
|
|
|
.addFile(path.join(__dirname, 'certs', 'server', 'my-root-ca.crt.pem'))
|
2014-07-15 03:20:49 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
options = {
|
2016-06-28 00:02:18 +00:00
|
|
|
key: fs.readFileSync(path.join(__dirname, 'certs', 'server', 'privkey.pem'))
|
2014-07-15 03:20:49 +00:00
|
|
|
// You don't need to specify `ca`, it's done by `ssl-root-cas`
|
2014-07-16 04:54:02 +00:00
|
|
|
//, ca: [ fs.readFileSync(path.join(__dirname, 'certs', 'server', 'my-root-ca.crt.pem'))]
|
2016-06-28 00:02:18 +00:00
|
|
|
, cert: fs.readFileSync(path.join(__dirname, 'certs', 'server', 'fullchain.pem'))
|
2014-07-15 03:20:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function app(req, res) {
|
|
|
|
res.setHeader('Content-Type', 'text/plain');
|
|
|
|
res.end('Hello, encrypted world!');
|
|
|
|
}
|
|
|
|
|
|
|
|
server = https.createServer(options, app).listen(port, function () {
|
|
|
|
port = server.address().port;
|
|
|
|
console.log('Listening on https://127.0.0.1:' + port);
|
|
|
|
console.log('Listening on https://' + server.address().address + ':' + port);
|
2016-06-28 00:02:18 +00:00
|
|
|
console.log('Listening on https://localhost.daplie.com:' + port);
|
2014-07-15 03:20:49 +00:00
|
|
|
});
|