diff --git a/README.md b/README.md index aaf1eb4c1..36ac9f3f8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Features * Connect and authenticate to individual databases * Authenticate as admin to view all databases * Database blacklist/whitelist +* Custom CA and CA validation disabling Screenshots @@ -125,6 +126,7 @@ You can use the following [environment variables](https://docs.docker.com/refere `ME_CONFIG_REQUEST_SIZE` | `100kb` | Used to configure maximum mongo update payload size. CRUD operations above this size will fail due to restrictions in [body-parser](https://www.npmjs.com/package/body-parser). `ME_CONFIG_OPTIONS_EDITORTHEME` | `rubyblue` | Web editor color theme, [more here](http://codemirror.net/demo/theme.html). `ME_CONFIG_SITE_SSL_ENABLED` | `false` | Enable SSL. + `ME_CONFIG_MONGODB_SSLVALIDATE` | `true` | Validate mongod server certificate against CA `ME_CONFIG_SITE_SSL_CRT_PATH` | ` ` | SSL certificate file. `ME_CONFIG_SITE_SSL_KEY_PATH` | ` ` | SSL key file. diff --git a/config.default.js b/config.default.js index 9545c2ab5..248545d4a 100644 --- a/config.default.js +++ b/config.default.js @@ -33,8 +33,14 @@ module.exports = { server: process.env.ME_CONFIG_MONGODB_SERVER || mongo.host, port: process.env.ME_CONFIG_MONGODB_PORT || mongo.port, - //useSSL: connect to the server using secure SSL - useSSL: process.env.ME_CONFIG_MONGODB_SSL || mongo.ssl, + //ssl: connect to the server using secure SSL + ssl: process.env.ME_CONFIG_MONGODB_SSL || mongo.ssl, + + //sslValidate: validate mongod server certificate against CA + sslValidate: process.env.ME_CONFIG_MONGODB_SSLVALIDATE || true, + + //sslCA: array of valid CA certificates + sslCA: [], //autoReconnect: automatically reconnect if connection is lost autoReconnect: true, diff --git a/lib/db.js b/lib/db.js index c26dadd30..cd478d3ac 100644 --- a/lib/db.js +++ b/lib/db.js @@ -8,10 +8,18 @@ let connect = function (config) { // set up database stuff let host = config.mongodb.server || 'localhost'; let port = config.mongodb.port || mongodb.Connection.DEFAULT_PORT; + + if (config.mongodb.useSSL) { + console.error('Please update config file to use mongodb.ssl instead of mongodb.useSSL. Copying value for now.'); + config.mongodb.ssl = config.mongodb.useSSL; + } + let dbOptions = { auto_reconnect: config.mongodb.autoReconnect, poolSize: config.mongodb.poolSize, - ssl: config.mongodb.useSSL, + ssl: config.mongodb.ssl, + sslValidate: config.mongodb.sslValidate, + sslCA: config.mongodb.sslCA, }; let db;