Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
fixing up SSL support on startup to fallback to non-SSL mode if files…
Browse files Browse the repository at this point in the history
… are not present
  • Loading branch information
lirantal committed Jul 17, 2015
1 parent e1605b6 commit 03b7f6f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,34 @@ 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';
}
// Reset console color
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
*/
Expand Down Expand Up @@ -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
Expand Down
Empty file modified scripts/generate-ssl-certs.sh
100644 → 100755
Empty file.
Empty file modified scripts/reset-password.js
100644 → 100755
Empty file.

0 comments on commit 03b7f6f

Please sign in to comment.