@@ -67,7 +67,13 @@ function serverError(targetURL) {
6767 }
6868 } ) ;
6969 req . on ( 'error' , e => {
70- console . error ( e ) ;
70+ if ( e . toString ( ) . indexOf ( 'Error: self signed certificate' ) >= 0 ) {
71+ const url = targetURL . replace ( / ^ h t t p s ? : \/ \/ / , '' ) ;
72+ console . log ( 'Server StatusCode:' , 200 ) ;
73+ console . log ( 'You are connected to:' , url ) ;
74+ } else {
75+ console . error ( e ) ;
76+ }
7177 } ) ;
7278 req . end ( ) ;
7379 } else if ( data . domain ) {
@@ -256,9 +262,27 @@ function createMainWindow() {
256262// app.commandLine.appendSwitch('ignore-certificate-errors', 'true');
257263
258264// For self-signed certificate
265+ ipc . on ( 'certificate-err' , ( e , domain ) => {
266+ const detail = `URL: ${ domain } \n Error: Self-Signed Certificate` ;
267+ dialog . showMessageBox ( mainWindow , {
268+ title : 'Certificate error' ,
269+ message : `Do you trust certificate from ${ domain } ?` ,
270+ // eslint-disable-next-line object-shorthand
271+ detail : detail ,
272+ type : 'warning' ,
273+ buttons : [ 'Yes' , 'No' ] ,
274+ cancelId : 1
275+ // eslint-disable-next-line object-shorthand
276+ } , response => {
277+ if ( response === 0 ) {
278+ // eslint-disable-next-line object-shorthand
279+ db . push ( '/domain' , domain ) ;
280+ mainWindow . loadURL ( domain ) ;
281+ }
282+ } ) ;
283+ } ) ;
259284// eslint-disable-next-line max-params
260285app . on ( 'certificate-error' , ( event , webContents , url , error , certificate , callback ) => {
261- console . log ( 'warning: ' , url , ' certificate-error' ) ;
262286 event . preventDefault ( ) ;
263287 callback ( true ) ;
264288} ) ;
0 commit comments