Skip to content

Commit

Permalink
🎉 Add support to ignore invalid HTTPs certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
snaildos committed Aug 27, 2022
1 parent 6e1f5f6 commit a54ae3d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/constants/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const DEFAULT_SETTINGS: ISettings = {
type: 'empty',
},
warnOnQuit: false,
version: 4,
version: 5,
downloadsDialog: false,
downloadsPath: app
? app.getPath('downloads')
Expand All @@ -64,6 +64,7 @@ export const DEFAULT_SETTINGS: ISettings = {
weather: false,
},
doNotTrack: true,
ignoreCertificate: false,
globalPrivacyControl: true,
topBarVariant: 'default',
};
1 change: 1 addition & 0 deletions src/interfaces/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface ISettings {
darkContents: boolean;
downloadsDialog: boolean;
downloadsPath: string;
ignoreCertificate: boolean;
doNotTrack: boolean;
topBarVariant: TopBarVariant;
token: string | null;
Expand Down
7 changes: 6 additions & 1 deletion src/main/view.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
/* Copyright (c) 2021-2022 SnailDOS */

import { BrowserView, app, ipcMain } from 'electron';
Expand Down Expand Up @@ -276,6 +277,9 @@ export class View {
}
});

const { object: settings } = Application.instance.settings;
if (settings.ignoreCertificate == false) {
app.commandLine.appendSwitch('ignore-certificate-errors');
this.webContents.addListener(
'certificate-error',
async (
Expand All @@ -287,12 +291,13 @@ export class View {
) => {
event.preventDefault();
this.errorURL = url;
await this.webContents.loadURL(
await this.webContents.loadURL(
`${ERROR_PROTOCOL}://${NETWORK_ERROR_HOST}/${error}`,
);
callback(false);
},
);
};

this.webContents.addListener('media-started-playing', () => {
this.emitEvent('media-playing', true);
Expand Down
24 changes: 23 additions & 1 deletion src/renderer/views/settings/components/Privacy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Button } from '~/renderer/components/Button';
import store from '../../store';
import { BLUE_500, RED_500 } from '~/renderer/constants';
import { observer } from 'mobx-react-lite';
import { onSwitchChange } from '../../utils';
import { onSwitchChange, alertSwitchChange } from '../../utils';
import { Switch } from '~/renderer/components/Switch';
import { ipcRenderer } from 'electron';

Expand Down Expand Up @@ -71,6 +71,27 @@ const GlobalPrivacyControlToggle = observer(() => {
);
});

const CertificateToggle = observer(() => {
const { ignoreCertificate } = store.settings;

return (
<Row onClick={alertSwitchChange('ignoreCertificate')}>
<Title>
Ignore &quot;HTTPS Certificates&quot; and if they are expired.
<br></br>
<b>
WARNING. If you do toggle this on, please toggle it back on. This
protects you against phising, hijacked websites and network
interceptions. Turning this on should only be LAST RESORT.
</b>
</Title>
<Control>
<Switch value={ignoreCertificate} />
</Control>
</Row>
);
});

export const Privacy = () => {
return (
<>
Expand Down Expand Up @@ -102,6 +123,7 @@ export const Privacy = () => {
</Row>
<GlobalPrivacyControlToggle />
<DoNotTrackToggle />
<CertificateToggle />
</>
);
};

0 comments on commit a54ae3d

Please sign in to comment.