Browse Source

fix: avoid setting db ssl unless explicitly provided

pull/880/head
Nick 5 years ago
parent
commit
f7ebccbb43
2 changed files with 19 additions and 2 deletions
  1. 1
      server/app/data.yml
  2. 20
      server/core/db.js

1
server/app/data.yml

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

20
server/core/db.js

@ -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