| 30 | const { versionCheckMiddleware, checkVersion } = require('./lib/web/middleware/checkVersion') |
| 31 | |
| 32 | function createHttpServer () { |
| 33 | if (config.useSSL) { |
| 34 | const ca = (function () { |
| 35 | let i, len |
| 36 | const results = [] |
| 37 | for (i = 0, len = config.sslCAPath.length; i < len; i++) { |
| 38 | results.push(fs.readFileSync(config.sslCAPath[i], 'utf8')) |
| 39 | } |
| 40 | return results |
| 41 | })() |
| 42 | const options = { |
| 43 | key: fs.readFileSync(config.sslKeyPath, 'utf8'), |
| 44 | cert: fs.readFileSync(config.sslCertPath, 'utf8'), |
| 45 | ca: ca, |
| 46 | dhparam: fs.readFileSync(config.dhParamPath, 'utf8'), |
| 47 | requestCert: false, |
| 48 | rejectUnauthorized: false |
| 49 | } |
| 50 | return require('https').createServer(options, app) |
| 51 | } else { |
| 52 | return require('http').createServer(app) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | // server setup |
| 57 | var app = express() |