Use HTTPS by default and accept --key and --cert
This commit is contained in:
parent
784914be7a
commit
9f32dddf19
1 changed files with 8 additions and 12 deletions
20
lib/app.js
20
lib/app.js
|
|
@ -54,7 +54,12 @@ config.load(function(err, conf) {
|
|||
if (err) { console.log(err); process.exit(1); }
|
||||
atm.init(app, conf.config);
|
||||
|
||||
if (argv.https) {
|
||||
if (argv.http) {
|
||||
http.createServer(app).listen(port, function () {
|
||||
console.log('Express server listening on port ' + port + ' (http)');
|
||||
});
|
||||
}
|
||||
else {
|
||||
app.use(clientCertificateAuth({ rejectUnauthorized: false }, function(cert, done) {
|
||||
config.isAuthorized(cert.fingerprint, function(err, authorized) {
|
||||
if (err) {
|
||||
|
|
@ -66,13 +71,9 @@ config.load(function(err, conf) {
|
|||
});
|
||||
}));
|
||||
|
||||
var testkeys = path.join(__dirname, '..', 'testkeys');
|
||||
var privateKey = fs.readFileSync(path.join(testkeys, 'privatekey.pem'));
|
||||
var certificate = fs.readFileSync(path.join(testkeys, 'certificate.pem'));
|
||||
|
||||
var options = {
|
||||
key: privateKey,
|
||||
cert: certificate,
|
||||
key: fs.readFileSync(argv.key),
|
||||
cert: fs.readFileSync(argv.cert),
|
||||
requestCert: true,
|
||||
secureProtocol: 'TLSv1_method',
|
||||
ciphers: 'AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH',
|
||||
|
|
@ -83,9 +84,4 @@ config.load(function(err, conf) {
|
|||
console.log('Express server listening on port ' + port + ' (https)');
|
||||
});
|
||||
}
|
||||
else {
|
||||
http.createServer(app).listen(port, function () {
|
||||
console.log('Express server listening on port ' + port + ' (http)');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue