From 711181751f0a5ee183b74514a621e4aaa6da3dd7 Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Fri, 26 Jan 2024 02:06:35 +0000 Subject: feat: self signed certificates bypass (#1545) * feat: self signed certificates bypass * fix lint and vscode setting * Fix some mistakes and comments * forgot this one [skip ci] --- src/helpers/certs-helpers.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/helpers/certs-helpers.ts (limited to 'src/helpers') diff --git a/src/helpers/certs-helpers.ts b/src/helpers/certs-helpers.ts new file mode 100644 index 000000000..a81e7e365 --- /dev/null +++ b/src/helpers/certs-helpers.ts @@ -0,0 +1,25 @@ +import { readdirSync, readFileSync, ensureDirSync } from 'fs-extra'; +import { join } from 'node:path'; +import { userDataCertsPath } from '../environment-remote'; + +export function removeNewLines(string: string) { + return string.replaceAll(/\r?\n|\r/g, ''); +} + +export function readCerts() { + const certsFolder = userDataCertsPath(); + + ensureDirSync(certsFolder); + + const certs: string[] = []; + + for (const file of readdirSync(certsFolder)) { + const cert = readFileSync(join(certsFolder, file), { + encoding: 'utf8', + flag: 'r', + }); + certs.push(removeNewLines(cert)); + } + + return certs; +} -- cgit v1.2.3-54-g00ecf