mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 14:26:38 +00:00
parse out sslmode from connectionUri under certain conditions
This commit is contained in:
@@ -32,10 +32,27 @@ export const initDbConnection = ({
|
|||||||
return selectedReplica;
|
return selectedReplica;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Parse out ?sslmode=... from the connection URI if its not equal to "disable" and dbRootCert is defined
|
||||||
|
let modifiedDbConnectionUri = dbConnectionUri;
|
||||||
|
if (dbRootCert) {
|
||||||
|
const parts = dbConnectionUri.split("?");
|
||||||
|
const baseUrl = parts[0];
|
||||||
|
const queryString = parts.length > 1 ? parts[1] : "";
|
||||||
|
|
||||||
|
if (queryString) {
|
||||||
|
const params = new URLSearchParams(queryString);
|
||||||
|
if (params.has("sslmode") && params.get("sslmode") !== "disable") {
|
||||||
|
params.delete("sslmode");
|
||||||
|
const newQueryString = params.toString();
|
||||||
|
modifiedDbConnectionUri = baseUrl + (newQueryString ? `?${newQueryString}` : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
db = knex({
|
db = knex({
|
||||||
client: "pg",
|
client: "pg",
|
||||||
connection: {
|
connection: {
|
||||||
connectionString: dbConnectionUri,
|
connectionString: modifiedDbConnectionUri,
|
||||||
host: process.env.DB_HOST,
|
host: process.env.DB_HOST,
|
||||||
// @ts-expect-error I have no clue why only for the port there is a type error
|
// @ts-expect-error I have no clue why only for the port there is a type error
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
|||||||
Reference in New Issue
Block a user