From 02816b68d053a44f8a4c69b724e55b88bb59b0d1 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Mon, 20 Apr 2020 22:00:59 -0400 Subject: [PATCH] fix: db inline CA cert reconstruct --- server/core/db.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/core/db.js b/server/core/db.js index b1e02485..00126e09 100644 --- a/server/core/db.js +++ b/server/core/db.js @@ -62,11 +62,16 @@ module.exports = { } // Handle inline SSL CA Certificate mode - if (!_.isEmpty(process.env.DB_SSL_CA) && process.env.DB_SSL_CA) { + if (!_.isEmpty(process.env.DB_SSL_CA)) { + const chunks = [] + for (let i = 0, charsLength = process.env.DB_SSL_CA.length; i < charsLength; i += 64) { + chunks.push(process.env.DB_SSL_CA.substring(i, i + 64)) + } + dbUseSSL = true sslOptions = { rejectUnauthorized: true, - ca: process.env.DB_SSL_CA + ca: '-----BEGIN CERTIFICATE-----\n' + chunks.join('\n') + '\n-----END CERTIFICATE-----\n' } }