From 3df3c97deb284ecbf3363b90a45c6501957d1e98 Mon Sep 17 00:00:00 2001 From: Ashex Date: Mon, 26 Jun 2023 14:54:16 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20support=20for=20SSL=20dat?= =?UTF-8?q?a=20when=20loading=20redis=20and=20postgres=20configs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #10366 --- packages/backend/ormconfig.js | 4 ++++ packages/backend/src/db/postgre.ts | 9 +++++++++ packages/backend/src/db/redis.ts | 5 +++++ packages/backend/src/queue/initialize.ts | 4 ++++ 4 files changed, 22 insertions(+) diff --git a/packages/backend/ormconfig.js b/packages/backend/ormconfig.js index 5f85cead8..c230e09fd 100644 --- a/packages/backend/ormconfig.js +++ b/packages/backend/ormconfig.js @@ -12,4 +12,8 @@ export default new DataSource({ extra: config.db.extra, entities: entities, migrations: ["migration/*.js"], + ssl: { + rejectUnauthorized: false, + ca: process.env.DB_SSL_CERT, + }, }); diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index 0fa5fdff6..85c4e424a 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -207,9 +207,14 @@ export const db = new DataSource({ host: config.redis.host, port: config.redis.port, family: config.redis.family == null ? 0 : config.redis.family, + user: "default", password: config.redis.pass, keyPrefix: `${config.redis.prefix}:query:`, db: config.redis.db || 0, + tls: { + host: config.redis.host, + rejectUnauthorized: false, + }, }, } : false, @@ -218,6 +223,10 @@ export const db = new DataSource({ maxQueryExecutionTime: 300, entities: entities, migrations: ["../../migration/*.js"], + ssl: { + rejectUnauthorized: false, + ca: process.env.DB_SSL_CERT, + }, }); export async function initDb(force = false) { diff --git a/packages/backend/src/db/redis.ts b/packages/backend/src/db/redis.ts index 6ad3de386..0a88a0deb 100644 --- a/packages/backend/src/db/redis.ts +++ b/packages/backend/src/db/redis.ts @@ -7,8 +7,13 @@ export function createConnection() { host: config.redis.host, family: config.redis.family == null ? 0 : config.redis.family, password: config.redis.pass, + username: "default", keyPrefix: `${config.redis.prefix}:`, db: config.redis.db || 0, + tls: { + rejectUnauthorized: false, + host: config.redis.host, + }, }); } diff --git a/packages/backend/src/queue/initialize.ts b/packages/backend/src/queue/initialize.ts index 0686fe9cd..4d7facd13 100644 --- a/packages/backend/src/queue/initialize.ts +++ b/packages/backend/src/queue/initialize.ts @@ -7,8 +7,12 @@ export function initialize(name: string, limitPerSec = -1) { port: config.redis.port, host: config.redis.host, family: config.redis.family == null ? 0 : config.redis.family, + user: "default", password: config.redis.pass, db: config.redis.db || 0, + tls: { + host: config.redis.host, + }, }, prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : "queue", limiter: