@@ -56,16 +56,34 @@ var validateEnvironmentVariable = function() {
56
56
console . log ( ) ;
57
57
if ( ! environmentFiles . length ) {
58
58
if ( process . env . NODE_ENV ) {
59
- console . error ( chalk . red ( 'No configuration file found for "' + process . env . NODE_ENV + '" environment using development instead' ) ) ;
59
+ console . error ( chalk . red ( '+ Error: No configuration file found for "' + process . env . NODE_ENV + '" environment using development instead' ) ) ;
60
60
} else {
61
- console . error ( chalk . red ( 'NODE_ENV is not defined! Using default development environment' ) ) ;
61
+ console . error ( chalk . red ( '+ Error: NODE_ENV is not defined! Using default development environment' ) ) ;
62
62
}
63
63
process . env . NODE_ENV = 'development' ;
64
64
}
65
65
// Reset console color
66
66
console . log ( chalk . white ( '' ) ) ;
67
67
} ;
68
68
69
+ /**
70
+ * Validate Secure=true parameter can actually be turned on
71
+ * because it requires certs and key files to be available
72
+ */
73
+ var validateSecureMode = function ( config ) {
74
+
75
+ if ( config . secure !== true )
76
+ return true ;
77
+
78
+ var privateKey = fs . existsSync ( './config/sslcerts/key.pem' ) ;
79
+ var certificate = fs . existsSync ( './config/sslcerts/cert.pem' ) ;
80
+
81
+ if ( ! privateKey || ! certificate ) {
82
+ chalk . red ( console . log ( '+ Error: Certificate file or key file is missing, falling back to non-SSL mode' ) ) ;
83
+ config . secure = false ;
84
+ }
85
+ } ;
86
+
69
87
/**
70
88
* Initialize global configuration files
71
89
*/
@@ -148,6 +166,9 @@ var initGlobalConfig = function() {
148
166
// Initialize global globbed folders
149
167
initGlobalConfigFolders ( config , assets ) ;
150
168
169
+ // Validate Secure SSL mode can be used
170
+ validateSecureMode ( config ) ;
171
+
151
172
// Expose configuration utilities
152
173
config . utils = {
153
174
getGlobbedPaths : getGlobbedPaths
0 commit comments