diff --git a/lib/app.js b/lib/app.js index 43421253..12f8cc77 100755 --- a/lib/app.js +++ b/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)'); - }); - } });