Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
81732da7
Commit
81732da7
authored
Apr 20, 2020
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: db inline CA cert mode
parent
d651412d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
db.js
server/core/db.js
+21
-5
No files found.
server/core/db.js
View file @
81732da7
...
...
@@ -26,6 +26,8 @@ module.exports = {
init
()
{
let
self
=
this
// Fetch DB Config
let
dbClient
=
null
let
dbConfig
=
(
!
_
.
isEmpty
(
process
.
env
.
DATABASE_URL
))
?
process
.
env
.
DATABASE_URL
:
{
host
:
WIKI
.
config
.
db
.
host
.
toString
(),
...
...
@@ -35,12 +37,15 @@ module.exports = {
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'
)
// Handle SSL Options
let
dbUseSSL
=
(
WIKI
.
config
.
db
.
ssl
===
true
||
WIKI
.
config
.
db
.
ssl
===
'true'
||
WIKI
.
config
.
db
.
ssl
===
1
||
WIKI
.
config
.
db
.
ssl
===
'1'
)
let
sslOptions
=
null
if
(
dbUseSSL
&&
_
.
isPlainObject
(
dbConfig
)
&&
_
.
get
(
dbConfig
,
'sslOptions.auto'
,
null
)
===
false
)
{
sslOptions
=
dbConfig
.
sslOptions
sslOptions
.
rejectUnauthorized
=
_
.
get
(
sslOptions
,
'rejectUnauthorized'
,
true
)
if
(
sslOptions
.
ca
)
{
if
(
dbUseSSL
&&
_
.
isPlainObject
(
dbConfig
)
&&
_
.
get
(
WIKI
.
config
.
db
,
'sslOptions.auto'
,
null
)
===
false
)
{
sslOptions
=
WIKI
.
config
.
db
.
sslOptions
// eslint-disable-next-line no-unneeded-ternary
sslOptions
.
rejectUnauthorized
=
sslOptions
.
rejectUnauthorized
===
false
?
false
:
true
if
(
sslOptions
.
ca
&&
sslOptions
.
ca
.
indexOf
(
'-----'
)
!==
0
)
{
sslOptions
.
ca
=
fs
.
readFileSync
(
path
.
resolve
(
WIKI
.
ROOTPATH
,
sslOptions
.
ca
))
}
if
(
sslOptions
.
cert
)
{
...
...
@@ -56,6 +61,16 @@ module.exports = {
sslOptions
=
true
}
// Handle inline SSL CA Certificate mode
if
(
!
_
.
isEmpty
(
process
.
env
.
DB_SSL_CA
)
&&
process
.
env
.
DB_SSL_CA
)
{
dbUseSSL
=
true
sslOptions
=
{
rejectUnauthorized
:
true
,
ca
:
process
.
env
.
DB_SSL_CA
}
}
// Engine-specific config
switch
(
WIKI
.
config
.
db
.
type
)
{
case
'postgres'
:
dbClient
=
'pg'
...
...
@@ -100,6 +115,7 @@ module.exports = {
process
.
exit
(
1
)
}
// Initialize Knex
this
.
knex
=
Knex
({
client
:
dbClient
,
useNullAsDefault
:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment