diff --git a/src/lib/core/config.js b/src/lib/core/config.js index 122e545e4..26a4c1199 100644 --- a/src/lib/core/config.js +++ b/src/lib/core/config.js @@ -483,6 +483,7 @@ Config.prototype.loadWebServerConfigFile = function() { }; webServerConfig.protocol = 'https'; } catch (e) { + webServerConfig.certOptions = {}; webServerConfig.protocol = 'http'; } } diff --git a/src/lib/modules/authenticator/index.js b/src/lib/modules/authenticator/index.js index 5bef5f1a9..4bdc6831c 100644 --- a/src/lib/modules/authenticator/index.js +++ b/src/lib/modules/authenticator/index.js @@ -62,11 +62,11 @@ class Authenticator { let self = this; this.events.once('outputDone', () => { - const {port, host, enabled} = this.embark.config.webServerConfig; + const {protocol, port, host, enabled} = this.embark.config.webServerConfig; if (enabled) { this.logger.info(__('Access the web backend with the following url: %s', - (`http://${host}:${port}/embark?token=${this.authToken}`.underline))); + (`${protocol}://${host}:${port}/embark?token=${this.authToken}`.underline))); } }); diff --git a/src/lib/modules/blockchain_process/blockchain.js b/src/lib/modules/blockchain_process/blockchain.js index c2ecb9002..064af13e9 100644 --- a/src/lib/modules/blockchain_process/blockchain.js +++ b/src/lib/modules/blockchain_process/blockchain.js @@ -27,6 +27,7 @@ var Blockchain = function(userConfig, clientClass) { this.events = userConfig.events; this.proxyIpc = null; this.isStandalone = userConfig.isStandalone; + this.certOptions = userConfig.certOptions; let defaultWsApi = clientClass.DEFAULTS.WS_API; @@ -150,10 +151,10 @@ Blockchain.prototype.setupProxy = async function () { let wsProxy; if (this.config.wsRPC) { - wsProxy = proxy.serve(this.proxyIpc, this.config.wsHost, this.config.wsPort, true, this.config.wsOrigins); + wsProxy = proxy.serve(this.proxyIpc, this.config.wsHost, this.config.wsPort, true, this.config.wsOrigins, this.certOptions); } - [this.rpcProxy, this.wsProxy] = await Promise.all([proxy.serve(this.proxyIpc, this.config.rpcHost, this.config.rpcPort, false), wsProxy]); + [this.rpcProxy, this.wsProxy] = await Promise.all([proxy.serve(this.proxyIpc, this.config.rpcHost, this.config.rpcPort, false, undefined, this.certOptions), wsProxy]); }; Blockchain.prototype.shutdownProxy = function () { @@ -446,7 +447,7 @@ Blockchain.prototype.initChainAndGetAddress = function (callback) { }); }; -var BlockchainClient = function(userConfig, clientName, env, onReadyCallback, onExitCallback, logger, _events, _isStandalone) { +var BlockchainClient = function(userConfig, clientName, env, certOptions, onReadyCallback, onExitCallback, logger, _events, _isStandalone) { if ((userConfig === {} || JSON.stringify(userConfig) === '{"enabled":true}') && env !== 'development') { logger.info("===> " + __("warning: running default config on a non-development environment")); } @@ -473,6 +474,7 @@ var BlockchainClient = function(userConfig, clientName, env, onReadyCallback, on userConfig.onReadyCallback = onReadyCallback; userConfig.onExitCallback = onExitCallback; userConfig.logger = logger; + userConfig.certOptions = certOptions; return new Blockchain(userConfig, clientClass); }; diff --git a/src/lib/modules/blockchain_process/blockchainProcess.js b/src/lib/modules/blockchain_process/blockchainProcess.js index 3f6b62bb2..e44d72223 100644 --- a/src/lib/modules/blockchain_process/blockchainProcess.js +++ b/src/lib/modules/blockchain_process/blockchainProcess.js @@ -12,6 +12,7 @@ class BlockchainProcess extends ProcessWrapper { this.client = options.client; this.env = options.env; this.isDev = options.isDev; + this.certOptions = options.certOptions; i18n.setOrDetectLocale(options.locale); @@ -20,6 +21,7 @@ class BlockchainProcess extends ProcessWrapper { this.blockchainConfig, this.client, this.env, + this.certOptions, this.blockchainReady.bind(this), this.blockchainExit.bind(this), console diff --git a/src/lib/modules/blockchain_process/blockchainProcessLauncher.js b/src/lib/modules/blockchain_process/blockchainProcessLauncher.js index c3e45905c..6bf058b72 100644 --- a/src/lib/modules/blockchain_process/blockchainProcessLauncher.js +++ b/src/lib/modules/blockchain_process/blockchainProcessLauncher.js @@ -37,7 +37,8 @@ class BlockchainProcessLauncher { client: this.client, env: this.env, isDev: this.isDev, - locale: this.locale + locale: this.locale, + certOptions: this.embark.config.webServerConfig.certOptions } }); diff --git a/src/lib/modules/blockchain_process/proxy.js b/src/lib/modules/blockchain_process/proxy.js index c3ad2d5e7..478b205e0 100644 --- a/src/lib/modules/blockchain_process/proxy.js +++ b/src/lib/modules/blockchain_process/proxy.js @@ -36,7 +36,7 @@ const parseJsonMaybe = (string) => { return object; }; -exports.serve = async (ipc, host, port, ws, origin) => { +exports.serve = async (ipc, host, port, ws, origin, certOptions={}) => { const commList = {}; const receipts = {}; const transactions = {}; @@ -123,6 +123,7 @@ exports.serve = async (ipc, host, port, ws, origin) => { logLevel: 'warn', target: `http://${canonicalHost(host)}:${port}`, ws: ws, + ssl: certOptions, onError(err, _req, _res) { console.error( diff --git a/src/lib/modules/blockchain_process/simulator.js b/src/lib/modules/blockchain_process/simulator.js index 5c503f986..ebfce2756 100644 --- a/src/lib/modules/blockchain_process/simulator.js +++ b/src/lib/modules/blockchain_process/simulator.js @@ -86,7 +86,7 @@ class Simulator { if(useProxy){ let ipcObject = new Ipc({ipcRole: 'client'}); - proxy.serve(ipcObject, host, port, false); + proxy.serve(ipcObject, host, port, false, undefined); } } }