aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers/certs-helpers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/certs-helpers.ts')
-rw-r--r--src/helpers/certs-helpers.ts25
1 files changed, 25 insertions, 0 deletions
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 @@
1import { readdirSync, readFileSync, ensureDirSync } from 'fs-extra';
2import { join } from 'node:path';
3import { userDataCertsPath } from '../environment-remote';
4
5export function removeNewLines(string: string) {
6 return string.replaceAll(/\r?\n|\r/g, '');
7}
8
9export function readCerts() {
10 const certsFolder = userDataCertsPath();
11
12 ensureDirSync(certsFolder);
13
14 const certs: string[] = [];
15
16 for (const file of readdirSync(certsFolder)) {
17 const cert = readFileSync(join(certsFolder, file), {
18 encoding: 'utf8',
19 flag: 'r',
20 });
21 certs.push(removeNewLines(cert));
22 }
23
24 return certs;
25}