diff options
author | 2024-01-26 02:06:35 +0000 | |
---|---|---|
committer | 2024-01-26 02:06:35 +0000 | |
commit | 711181751f0a5ee183b74514a621e4aaa6da3dd7 (patch) | |
tree | 202718df2046fb92761abc3379ae48f35774a92c /src/index.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/index.ts')
-rw-r--r-- | src/index.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts index e466b4ab1..8419d5cf9 100644 --- a/src/index.ts +++ b/src/index.ts | |||
@@ -50,6 +50,7 @@ import { openExternalUrl } from './helpers/url-helpers'; | |||
50 | import userAgent from './helpers/userAgent-helpers'; | 50 | import userAgent from './helpers/userAgent-helpers'; |
51 | import { translateTo } from './helpers/translation-helpers'; | 51 | import { translateTo } from './helpers/translation-helpers'; |
52 | import { darkThemeGrayDarkest } from './themes/legacy'; | 52 | import { darkThemeGrayDarkest } from './themes/legacy'; |
53 | import { readCerts, removeNewLines } from './helpers/certs-helpers'; | ||
53 | 54 | ||
54 | const debug = require('./preload-safe-debug')('Ferdium:App'); | 55 | const debug = require('./preload-safe-debug')('Ferdium:App'); |
55 | 56 | ||
@@ -752,3 +753,41 @@ app.on('will-finish-launching', () => { | |||
752 | }); | 753 | }); |
753 | }); | 754 | }); |
754 | }); | 755 | }); |
756 | |||
757 | app.on( | ||
758 | 'certificate-error', | ||
759 | (event, _webContents, _url, _error, certificate, callback) => { | ||
760 | // On certificate error we disable default behaviour (stop loading the page) | ||
761 | // and we then say "it is all fine - true" to the callback | ||
762 | event.preventDefault(); | ||
763 | |||
764 | const useSelfSignedCertificates = | ||
765 | retrieveSettingValue( | ||
766 | 'useSelfSignedCertificates', | ||
767 | DEFAULT_APP_SETTINGS.useSelfSignedCertificates, | ||
768 | ) === true; | ||
769 | |||
770 | // Check if the certificate is trusted | ||
771 | if (!useSelfSignedCertificates) { | ||
772 | callback(false); | ||
773 | return; | ||
774 | } | ||
775 | |||
776 | const trustedCerts = readCerts(); | ||
777 | if (!trustedCerts) { | ||
778 | callback(false); | ||
779 | return; | ||
780 | } | ||
781 | |||
782 | const isTrustedCert = trustedCerts.includes( | ||
783 | removeNewLines(certificate.data), | ||
784 | ); | ||
785 | |||
786 | if (isTrustedCert) { | ||
787 | callback(true); | ||
788 | return; | ||
789 | } | ||
790 | |||
791 | callback(false); | ||
792 | }, | ||
793 | ); | ||