This commit is contained in:
syuilo
2019-02-07 21:02:33 +09:00
parent 27768081e2
commit 5448c22031
19 changed files with 125 additions and 194 deletions

View File

@@ -96,14 +96,13 @@ app.use(router.routes());
app.use(mount(require('./web')));
function createServer() {
if (config.https.isJust()) {
const opts = {
key: fs.readFileSync(config.https.get().key),
cert: fs.readFileSync(config.https.get().cert),
...config.https.get().ca.map<any>(path => ({ ca: fs.readFileSync(path) })).getOrElse({}),
allowHTTP1: true
};
return http2.createSecureServer(opts, app.callback()) as https.Server;
if (config.https) {
const certs: any = {};
for (const k of Object.keys(config.https)) {
certs[k] = fs.readFileSync(config.https[k]);
}
certs['allowHTTP1'] = true;
return http2.createSecureServer(certs, app.callback()) as https.Server;
} else {
return http.createServer(app.callback());
}