diff options
author | 2024-01-26 02:06:35 +0000 | |
---|---|---|
committer | 2024-01-26 02:06:35 +0000 | |
commit | 711181751f0a5ee183b74514a621e4aaa6da3dd7 (patch) | |
tree | 202718df2046fb92761abc3379ae48f35774a92c /src/helpers/certs-helpers.ts | |
parent | 6.7.1-nightly.10 [skip ci] (diff) | |
download | ferdium-app-711181751f0a5ee183b74514a621e4aaa6da3dd7.tar.gz ferdium-app-711181751f0a5ee183b74514a621e4aaa6da3dd7.tar.zst ferdium-app-711181751f0a5ee183b74514a621e4aaa6da3dd7.zip |
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]
Diffstat (limited to 'src/helpers/certs-helpers.ts')
-rw-r--r-- | src/helpers/certs-helpers.ts | 25 |
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 @@ | |||
1 | import { readdirSync, readFileSync, ensureDirSync } from 'fs-extra'; | ||
2 | import { join } from 'node:path'; | ||
3 | import { userDataCertsPath } from '../environment-remote'; | ||
4 | |||
5 | export function removeNewLines(string: string) { | ||
6 | return string.replaceAll(/\r?\n|\r/g, ''); | ||
7 | } | ||
8 | |||
9 | export 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 | } | ||