diff --git a/packages/app/src/app/duck.js b/packages/app/src/app/duck.js index 5a064bf4..cc3a20d0 100644 --- a/packages/app/src/app/duck.js +++ b/packages/app/src/app/duck.js @@ -32,6 +32,7 @@ export const OPEN_PROCESS_MANAGER = 'browserX/app/OPEN_PROCESS_MANAGER'; export const TOGGLE_PROMPT_DOWNLOAD = 'browserX/app/TOGGLE_PROMPT_DOWNLOAD'; export const SET_APP_METADATA = 'browserX/app/SET_APP_METADATA'; +export const DISABLE_SSL_CERT_VERIFICATION = 'browserX/app/DISABLE_SSL_CERT_VERIFICATION'; // Action creators export const ready = () => ({ type: READY }); @@ -133,6 +134,11 @@ export const setAppMetadata = (metadata) => { }; }; +export const disableSslCertVerification = (partition) => ({ + type: DISABLE_SSL_CERT_VERIFICATION, + partition, +}); + // Reducer export default function app(state = new Map(), action) { switch (action.type) { diff --git a/packages/app/src/app/sagas.js b/packages/app/src/app/sagas.js index c38fa85c..d15d76d4 100644 --- a/packages/app/src/app/sagas.js +++ b/packages/app/src/app/sagas.js @@ -36,7 +36,8 @@ import { setLoadingScreenVisibility, TOGGLE_PROMPT_DOWNLOAD, TOGGLE_KBD_SHORTCUTS, - TOGGLE_MAXIMIZE + TOGGLE_MAXIMIZE, + DISABLE_SSL_CERT_VERIFICATION, } from './duck'; import { DELAY } from '../persistence/backend'; import { getWindowCurrentTabId } from '../windows/get'; @@ -249,6 +250,10 @@ function* sagaHandleOpenProcessManager() { yield callService('processManager', 'open', undefined); } +function* sagaDisableSslCertVerification({ partition }) { + yield callService('defaultSession', 'disableSslCertVerification', partition); +} + /** * Will load the app metadata in the state. */ @@ -275,6 +280,7 @@ export default function* main(bxApp) { takeEveryWitness(TOGGLE_KBD_SHORTCUTS, sagaToggleKbdShortcutsOverlay), takeEveryWitness(CHANGE_APP_FOCUS_STATE, onChangeAppFocusState), takeEveryWitness(OPEN_PROCESS_MANAGER, sagaHandleOpenProcessManager), + takeEveryWitness(DISABLE_SSL_CERT_VERIFICATION, sagaDisableSslCertVerification), // For dev purpose takeEveryWitness('STATION_MANUAL_ERR', sagaTriggerError) ]); diff --git a/packages/app/src/applications/Application.tsx b/packages/app/src/applications/Application.tsx index e7a34f3b..2e76674a 100644 --- a/packages/app/src/applications/Application.tsx +++ b/packages/app/src/applications/Application.tsx @@ -7,7 +7,6 @@ import { GradientType, withGradient } from '@getstation/theme'; import ElectronWebview from '../common/components/ElectronWebview'; import * as classNames from 'classnames'; import { clipboard } from 'electron'; -import * as remote from '@electron/remote'; // @ts-ignore no declaration file import { fetchFavicon, setFetchFaviconTimeout } from '@getstation/fetch-favicon'; import Maybe from 'graphql/tsutils/Maybe'; @@ -41,6 +40,8 @@ import { } from '../tab-webcontents/duck'; import { getTabWebcontentsById, getWebcontentsAuthInfo, getWebcontentsAuthState } from '../tab-webcontents/selectors'; import { updateLoadingState, updateTabBadge, updateTabFavicons, updateTabTitle, updateTabURL } from '../tabs/duck'; +// @ts-ignore no declaration file +import { disableSslCertVerification } from '../app/duck'; import { getTabId, getTabLoadingState } from '../tabs/get'; import { StationTabImmutable } from '../tabs/types'; import { RecursiveImmutableMap, StationState } from '../types'; @@ -51,6 +52,7 @@ import LazyWebview from './LazyWebview'; import { withGetApplicationState } from './queries@local.gql.generated'; import { getApplicationDescription } from './selectors'; import { ApplicationImmutable } from './types'; +// @ts-ignore no declaration file import { getForeFrontNavigationStateProperty } from './utils'; type WebviewMethod = (webview: ElectronWebview) => void; @@ -97,6 +99,7 @@ export interface OwnProps { loading: boolean, manifestURL: Maybe, applicationId: string, + appstoreApplicationId: string, applicationName: Maybe, applicationIcon: Maybe, @@ -142,6 +145,7 @@ export interface DispatchProps { onChooseAccount: Function, onApplicationRemoved: Function, updateResetAppModal: Function, + disableSslCertVerification: (partition: string) => any, } export interface ComputedProps { @@ -388,12 +392,10 @@ class ApplicationImpl extends React.PureComponent { const webview = this.webView.view; webview.addEventListener('dom-ready', () => { - const webContents = remote.webContents.fromId(webview.getWebContentsId()); - webview.addEventListener('did-navigate-in-page', (e: any) => this.handleDidNavigateInPage(e)); webview.addEventListener('did-navigate', (e: any) => this.handleDidNavigate(e)); webview.addEventListener('ipc-message', (e: any) => this.handleIPCMessage(e)); - this.props.onWebcontentsAttached(webContents.id); + this.props.onWebcontentsAttached(webview.getWebContentsId()); }); } } @@ -403,7 +405,8 @@ class ApplicationImpl extends React.PureComponent { const useNativeWindowOpen = !this.props.notUseNativeWindowOpen; const tabUrl = tab.get('url', ''); const { - applicationId, applicationName, applicationIcon, themeColor, manifestURL, + applicationId, applicationName, applicationIcon, + appstoreApplicationId, themeColor, manifestURL, askResetApplication, onChooseAccount, crashed, errorCode, errorDescription, canGoBack, themeGradient, email, @@ -411,6 +414,13 @@ class ApplicationImpl extends React.PureComponent { useDefaultSession, } = this.props; + const partition = useDefaultSession ? '' : `persist:${applicationId}`; + + // disable SSL check for private applications + if (!useDefaultSession && Number(appstoreApplicationId) > 1000000) { + this.props.disableSslCertVerification(partition); + } + return (
setConfigData(applicationId, { identityId }), onApplicationRemoved: uninstallApplication, updateResetAppModal: (appFocus) => updateUI('confirmResetApplicationModal', 'isVisible', appFocus), + disableSslCertVerification: disableSslCertVerification, }, dispatch ); diff --git a/packages/app/src/services/services/session/interface.ts b/packages/app/src/services/services/session/interface.ts index aea83309..acda258e 100644 --- a/packages/app/src/services/services/session/interface.ts +++ b/packages/app/src/services/services/session/interface.ts @@ -13,4 +13,6 @@ export class SessionService extends ServiceBase implements RPC.Interface {} // @ts-ignore getCookies(filter: Electron.CookiesGetFilter): Promise {} + // @ts-ignore + disableSslCertVerification(partition: string) : Promise {} } diff --git a/packages/app/src/services/services/session/main.ts b/packages/app/src/services/services/session/main.ts index 7be81844..d0fe0596 100644 --- a/packages/app/src/services/services/session/main.ts +++ b/packages/app/src/services/services/session/main.ts @@ -26,6 +26,13 @@ export class SessionServiceImpl extends SessionService implements RPC.Interface< return session.cookies.get(filter); } + async disableSslCertVerification(partition: string) : Promise { + const session = Electron.session.fromPartition(partition); + session.setCertificateVerifyProc((_, callback) => { + callback(0); + }); + } + private async initSession(options?: SessionOptions): Promise { if (options && options.partition) { return Electron.session.fromPartition(options.partition);