diff --git a/config/config.js b/config/config.js index cabe4654ef..943be98be5 100644 --- a/config/config.js +++ b/config/config.js @@ -56,9 +56,9 @@ var validateEnvironmentVariable = function() { console.log(); if (!environmentFiles.length) { if (process.env.NODE_ENV) { - console.error(chalk.red('No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead')); + console.error(chalk.red('+ Error: No configuration file found for "' + process.env.NODE_ENV + '" environment using development instead')); } else { - console.error(chalk.red('NODE_ENV is not defined! Using default development environment')); + console.error(chalk.red('+ Error: NODE_ENV is not defined! Using default development environment')); } process.env.NODE_ENV = 'development'; } @@ -66,6 +66,24 @@ var validateEnvironmentVariable = function() { console.log(chalk.white('')); }; +/** + * Validate Secure=true parameter can actually be turned on + * because it requires certs and key files to be available + */ +var validateSecureMode = function(config) { + + if (config.secure !== true) + return true; + + var privateKey = fs.existsSync('./config/sslcerts/key.pem'); + var certificate = fs.existsSync('./config/sslcerts/cert.pem'); + + if (!privateKey || !certificate) { + chalk.red(console.log('+ Error: Certificate file or key file is missing, falling back to non-SSL mode')); + config.secure = false; + } +}; + /** * Initialize global configuration files */ @@ -148,6 +166,9 @@ var initGlobalConfig = function() { // Initialize global globbed folders initGlobalConfigFolders(config, assets); + // Validate Secure SSL mode can be used + validateSecureMode(config); + // Expose configuration utilities config.utils = { getGlobbedPaths: getGlobbedPaths diff --git a/scripts/generate-ssl-certs.sh b/scripts/generate-ssl-certs.sh old mode 100644 new mode 100755 diff --git a/scripts/reset-password.js b/scripts/reset-password.js old mode 100644 new mode 100755