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); }
|
if (err) { console.log(err); process.exit(1); }
|
||||||
atm.init(app, conf.config);
|
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) {
|
app.use(clientCertificateAuth({ rejectUnauthorized: false }, function(cert, done) {
|
||||||
config.isAuthorized(cert.fingerprint, function(err, authorized) {
|
config.isAuthorized(cert.fingerprint, function(err, authorized) {
|
||||||
if (err) {
|
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 = {
|
var options = {
|
||||||
key: privateKey,
|
key: fs.readFileSync(argv.key),
|
||||||
cert: certificate,
|
cert: fs.readFileSync(argv.cert),
|
||||||
requestCert: true,
|
requestCert: true,
|
||||||
secureProtocol: 'TLSv1_method',
|
secureProtocol: 'TLSv1_method',
|
||||||
ciphers: 'AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH',
|
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)');
|
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