From a22570e94e90ddebf50cb26643f426e2c28b01d4 Mon Sep 17 00:00:00 2001 From: xangelo Date: Wed, 4 Dec 2024 15:27:42 -0500 Subject: [PATCH] chore(DO): trying loading cert form file --- knexfile.ts | 9 +++++---- src/server/lib/db.ts | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/knexfile.ts b/knexfile.ts index ea4b0b7..751c83b 100644 --- a/knexfile.ts +++ b/knexfile.ts @@ -1,9 +1,12 @@ import { config as dotenv } from 'dotenv'; import type { Knex } from "knex"; +import { readFileSync, writeFileSync } from 'fs'; +import path from 'path'; dotenv(); const connectionUrl = process.env.DATABASE_URL; +writeFileSync(path.join(__dirname, 'ca.cert'), process.env.CA_CERT as string); const config: { [key: string]: Knex.Config } = { development: { @@ -11,8 +14,7 @@ const config: { [key: string]: Knex.Config } = { connection: { connectionString: connectionUrl, ssl: { - rejectUnauthorized: false, - ca: process.env.CA_CERT + ca: readFileSync(path.join(__dirname, 'ca.crt')) } }, pool: { @@ -29,8 +31,7 @@ const config: { [key: string]: Knex.Config } = { connection: { connectionString: connectionUrl, ssl: { - rejectUnauthorized: false, - ca: process.env.CA_CERT + ca: readFileSync(path.join(__dirname, 'ca.crt')) } }, pool: { diff --git a/src/server/lib/db.ts b/src/server/lib/db.ts index 6a19281..7a0b7dc 100644 --- a/src/server/lib/db.ts +++ b/src/server/lib/db.ts @@ -1,17 +1,20 @@ import knex from "knex"; import { config as dotenv } from 'dotenv'; +import { readFileSync, writeFileSync } from 'fs'; +import path from 'path'; dotenv(); const connectionUrl = process.env.DATABASE_URL; +writeFileSync(path.join(__dirname, 'ca.crt'), process.env.CA_CERT as string); + export const db = knex({ client: 'pg', connection: { connectionString: connectionUrl, ssl: { - rejectUnauthorized: false, - ca: process.env.CA_CERT + ca: readFileSync(path.join(__dirname, 'ca.crt')) } } }); -- 2.25.1