From b19aea8c2861043965499be319b882704cb948c2 Mon Sep 17 00:00:00 2001 From: kenshin-samourai Date: Mon, 30 Sep 2019 16:34:25 +0200 Subject: [PATCH] removed unused support of https by nodejs apps --- accounts/index.js | 3 +- docker/my-dojo/node/keys.index.js | 39 ---------------------- keys/index-example.js | 55 ------------------------------- lib/http-server/http-server.js | 35 +++----------------- pushtx/index.js | 3 +- 5 files changed, 7 insertions(+), 128 deletions(-) diff --git a/accounts/index.js b/accounts/index.js index 484f745..e04e5c8 100644 --- a/accounts/index.js +++ b/accounts/index.js @@ -53,8 +53,7 @@ // Initialize the http server const port = keys.ports.account - const httpsOptions = keys.https.account - const httpServer = new HttpServer(port, httpsOptions) + const httpServer = new HttpServer(port) // Initialize the rest api endpoints const authRestApi = new AuthRestApi(httpServer) diff --git a/docker/my-dojo/node/keys.index.js b/docker/my-dojo/node/keys.index.js index 9ba3887..6189ba5 100644 --- a/docker/my-dojo/node/keys.index.js +++ b/docker/my-dojo/node/keys.index.js @@ -81,45 +81,6 @@ module.exports = { // Port used by the pushtx orchestrator for its notifications orchestrator: 5557 }, - /* - * HTTPS - * Activate only if node js is used as frontend web server - * (no nginx proxy server) - */ - https: { - // HTTPS for the API - account: { - // Activate https - active: false, - // Filepath of server private key - // (shoud be stored in keys/sslcert) - keypath: '', - // Passphrase of the private key - passphrase: '', - // Filepath of server certificate - // (shoud be stored in keys/sslcert) - certpath: '', - // Filepath of CA certificate - // (shoud be stored in keys/sslcert) - capath: '' - }, - // HTTPS for pushtx - pushtx: { - // Activate https - active: false, - // Filepath of server private key - // (shoud be stored in keys/sslcert) - keypath: '', - // Passphrase of the private key - passphrase: '', - // Filepath of server certificate - // (shoud be stored in keys/sslcert) - certpath: '', - // Filepath of CA certificate - // (shoud be stored in keys/sslcert) - capath: '' - } - }, /* * Authenticated access to the APIs (account & pushtx) */ diff --git a/keys/index-example.js b/keys/index-example.js index d73cc48..64ee7d5 100644 --- a/keys/index-example.js +++ b/keys/index-example.js @@ -78,45 +78,6 @@ module.exports = { // Port used by the pushtx orchestrator for its notifications orchestrator: 5557 }, - /* - * HTTPS - * Activate only if node js is used as frontend web server - * (no nginx proxy server) - */ - https: { - // HTTPS for the API - account: { - // Activate https - active: false, - // Filepath of server private key - // (shoud be stored in keys/sslcert) - keypath: '', - // Passphrase of the private key - passphrase: '', - // Filepath of server certificate - // (shoud be stored in keys/sslcert) - certpath: '', - // Filepath of CA certificate - // (shoud be stored in keys/sslcert) - capath: '' - }, - // HTTPS for pushtx - pushtx: { - // Activate https - active: false, - // Filepath of server private key - // (shoud be stored in keys/sslcert) - keypath: '', - // Passphrase of the private key - passphrase: '', - // Filepath of server certificate - // (shoud be stored in keys/sslcert) - certpath: '', - // Filepath of CA certificate - // (shoud be stored in keys/sslcert) - capath: '' - } - }, /* * Authenticated access to the APIs (account & pushtx) */ @@ -277,22 +238,6 @@ module.exports = { notifpushtx: 15556, orchestrator: 15557 }, - https: { - account: { - active: false, - keypath: '', - passphrase: '', - certpath: '', - capath: '' - }, - pushtx: { - active: false, - keypath: '', - passphrase: '', - certpath: '', - capath: '' - } - }, auth: { activeStrategy: null, mandatory: false, diff --git a/lib/http-server/http-server.js b/lib/http-server/http-server.js index 93ccb3b..9076be6 100644 --- a/lib/http-server/http-server.js +++ b/lib/http-server/http-server.js @@ -5,7 +5,6 @@ 'use strict' const fs = require('fs') -const https = require('https') const express = require('express') const helmet = require('helmet') const Logger = require('../logger') @@ -19,15 +18,11 @@ class HttpServer { /** * Constructor * @param {int} port - port used by the http server - * @param {object} httpsOptions - https options */ - constructor(port, httpsOptions) { + constructor(port) { // Initialize server port this.port = port - // Store https options - this.httpsOptions = httpsOptions - // Listening server instance this.server = null @@ -58,30 +53,10 @@ class HttpServer { HttpServer.sendError(res, ret, 500) }) - if (this.httpsOptions == null || !this.httpsOptions.active) { - // Start a http server - this.server = this.app.listen(this.port, () => { - Logger.info('HTTP server listening on port ' + this.port) - }) - } else { - // Start a https server - const options = { - key: fs.readFileSync(this.httpsOptions.keypath), - cert: fs.readFileSync(this.httpsOptions.certpath), - requestCert: false, - rejectUnauthorized: false - } - - if (this.httpsOptions.capath) - options.ca = fs.readFileSync(this.httpsOptions.capath) - - if (this.httpsOptions.passphrase) - options.passphrase = this.httpsOptions.passphrase - - this.server = https.createServer(options, this.app).listen(this.port, () => { - Logger.info('HTTPS server listening on port ' + this.port) - }) - } + // Start a http server + this.server = this.app.listen(this.port, () => { + Logger.info('HTTP server listening on port ' + this.port) + }) this.server.timeout = 600 * 1000 // @see https://github.com/nodejs/node/issues/13391 diff --git a/pushtx/index.js b/pushtx/index.js index c951d63..729830b 100644 --- a/pushtx/index.js +++ b/pushtx/index.js @@ -45,8 +45,7 @@ // Initialize the http server const port = keys.ports.pushtx - const httpsOptions = keys.https.pushtx - const httpServer = new HttpServer(port, httpsOptions) + const httpServer = new HttpServer(port) // Initialize the PushTx rest api const pushtxRestApi = new PushTxRestApi(httpServer)