Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit f786dda

Browse files
committed
moving security configs to secure code block to remove requirement for private key and certificate
1 parent 7946cfe commit f786dda

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

config/express.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
*/
66
var fs = require('fs'),
77
http = require('http'),
8-
https = require('https'),
9-
privateKey = fs.readFileSync('./config/sslcert/key.pem', 'utf8'),
10-
certificate = fs.readFileSync('./config/sslcert/cert.pem', 'utf8'),
11-
credentials = {key: privateKey, cert: certificate},
128
express = require('express'),
139
morgan = require('morgan'),
1410
bodyParser = require('body-parser'),
@@ -149,7 +145,11 @@ module.exports = function(db) {
149145

150146
if (app.locals.secure) {
151147
console.log('Securely using https protocol');
152-
var httpsServer = https.createServer(credentials, app);
148+
var https = require('https'),
149+
privateKey = fs.readFileSync('./config/sslcert/key.pem', 'utf8'),
150+
certificate = fs.readFileSync('./config/sslcert/cert.pem', 'utf8'),
151+
credentials = {key: privateKey, cert: certificate},
152+
httpsServer = https.createServer(credentials, app);
153153
return httpsServer;
154154
} else {
155155
console.log('Insecurely using http protocol');

0 commit comments

Comments
 (0)