@@ -55,7 +55,7 @@ if (manifestJsonFile.singleInstance || manifestJsonFile.aspCoreBackendPort) {
5555 args . forEach ( parameter => {
5656 const words = parameter . split ( '=' ) ;
5757
58- if ( words . length > 1 ) {
58+ if ( words . length > 1 ) {
5959 app . commandLine . appendSwitch ( words [ 0 ] . replace ( '--' , '' ) , words [ 1 ] ) ;
6060 } else {
6161 app . commandLine . appendSwitch ( words [ 0 ] . replace ( '--' , '' ) ) ;
@@ -76,6 +76,27 @@ if (manifestJsonFile.singleInstance || manifestJsonFile.aspCoreBackendPort) {
7676 }
7777}
7878
79+ // Bypass all SSL/TLS certificate errors. -- Less secure.
80+ if ( manifestJsonFile . ignoreAllCertificateErrors ) {
81+ console . log ( 'All SSL/TLS Certificate errors will be ignored.' ) ;
82+ app . commandLine . appendSwitch ( 'ignore-certificate-errors' ) ;
83+ }
84+
85+ // Bypass SSL/TLS certificate errors only for the domain names specified in the electron.manifest.json file.
86+ if ( manifestJsonFile . hasOwnProperty ( 'domainNamesToIgnoreCertificateErrors' ) ) {
87+ if ( manifestJsonFile . domainNamesToIgnoreCertificateErrors . length > 0 ) {
88+ console . log ( `SSL/TLS certificate errors will be ignored for ${ manifestJsonFile . domainNamesToIgnoreCertificateErrors . join ( ', ' ) } ` ) ;
89+
90+ app . on ( 'certificate-error' , ( event , webContents , url , error , certificate , callback ) => {
91+ if ( shouldIgnoreCertificateForUrl ( url ) ) {
92+ console . log ( 'SSL/TLS certificate error ignored for URL: ' + url ) ;
93+ event . preventDefault ( )
94+ callback ( true )
95+ }
96+ } )
97+ }
98+ }
99+
79100app . on ( 'ready' , ( ) => {
80101
81102 // Fix ERR_UNKNOWN_URL_SCHEME using file protocol
@@ -432,3 +453,15 @@ function getEnvironmentParameter() {
432453
433454 return '' ;
434455}
456+
457+ function shouldIgnoreCertificateForUrl ( url ) {
458+ if ( manifestJsonFile . hasOwnProperty ( 'domainNamesToIgnoreCertificateErrors' ) ) {
459+ // Removing the scheme from the url so it will cover https and wss://
460+ const urlWithoutScheme = url . replace ( / ( ^ \w + : | ^ ) \/ \/ / , '' ) ;
461+ const sites = manifestJsonFile . domainNamesToIgnoreCertificateErrors . filter ( ( oneSite ) => urlWithoutScheme . startsWith ( oneSite ) ) ;
462+
463+ return sites . length > 0 ;
464+ }
465+
466+ return false ;
467+ }
0 commit comments