fix: avoid setting db ssl unless explicitly provided

pull/880/head
Nick 6 years ago
parent a50bb2f281
commit f7ebccbb43

@ -14,6 +14,7 @@ defaults:
user: wikijs
pass: wikijsrocks
db: wiki
ssl: false
storage: ./db.sqlite
ssl:
enabled: false

@ -29,18 +29,27 @@ module.exports = {
user: WIKI.config.db.user,
password: WIKI.config.db.pass,
database: WIKI.config.db.db,
port: WIKI.config.db.port,
ssl: !_.isNil(WIKI.config.db.ssl) && WIKI.config.db.ssl !== false
port: WIKI.config.db.port
}
const dbUseSSL = (WIKI.config.db.ssl === true || WIKI.config.db.ssl === 'true' || WIKI.config.db.ssl === 1 || WIKI.config.db.ssl === '1')
switch (WIKI.config.db.type) {
case 'postgres':
dbClient = 'pg'
if (dbUseSSL && _.isPlainObject(dbConfig)) {
dbConfig.ssl = true
}
break
case 'mariadb':
case 'mysql':
dbClient = 'mysql2'
if (dbUseSSL && _.isPlainObject(dbConfig)) {
dbConfig.ssl = true
}
// Fix mysql boolean handling...
dbConfig.typeCast = (field, next) => {
if (field.type === 'TINY' && field.length === 1) {
@ -52,6 +61,13 @@ module.exports = {
break
case 'mssql':
dbClient = 'mssql'
if (_.isPlainObject(dbConfig)) {
dbConfig.appName = 'Wiki.js'
if (dbUseSSL) {
dbConfig.encrypt = true
}
}
break
case 'sqlite':
dbClient = 'sqlite3'

Loading…
Cancel
Save