Browse Source

Allow Self Signed Services

Fixes #88
pull/223/head
Ramiro Saenz 9 years ago
parent
commit
7459828936
  1. 4
      app/model/Service.js
  2. 3
      app/ux/WebView.js
  3. 10
      app/view/main/MainController.js
  4. 24
      electron/main.js

4
app/model/Service.js

@ -37,6 +37,10 @@ Ext.define('Rambox.model.Service', {
name: 'muted'
,type: 'boolean'
,defaultValue: false
},{
name: 'trust'
,type: 'boolean'
,defaultValue: false
},{
name: 'js_unread'
,type: 'string'

3
app/ux/WebView.js

@ -31,6 +31,9 @@ Ext.define('Rambox.ux.WebView',{
}
}
// Allow Custom sites with self certificates
if ( me.record.get('trust') ) require('electron').ipcRenderer.send('allowCertificate', me.src)
Ext.apply(me, {
items: [{
xtype: 'component'

10
app/view/main/MainController.js

@ -549,6 +549,14 @@ Ext.define('Rambox.view.main.MainController', {
,uncheckedValue: false
,inputValue: true
}
,{
xtype: 'checkbox'
,boxLabel: 'Trust invalid authority certificates'
,name: 'trust'
,checked: edit ? record.get('trust') : false
,uncheckedValue: false
,inputValue: true
}
]
}
,{
@ -602,6 +610,7 @@ Ext.define('Rambox.view.main.MainController', {
,align: formValues.align
,notifications: formValues.notifications
,muted: formValues.muted
,trust: formValues.trust
,js_unread: formValues.js_unread
});
@ -630,6 +639,7 @@ Ext.define('Rambox.view.main.MainController', {
,align: formValues.align
,notifications: formValues.notifications
,muted: formValues.muted
,trust: formValues.trust
,js_unread: formValues.js_unread !== '' ? 'function checkUnread(){updateBadge(' + formValues.js_unread + ')}function updateBadge(e){e>=1?document.title="("+e+") "+originalTitle:document.title=originalTitle}var originalTitle=document.title;setInterval(checkUnread,3000);' : ''
});
service.save();

24
electron/main.js

@ -179,9 +179,6 @@ function updateBadge(title) {
app.setBadgeCount(messageCount);
}
// Allow Custom sites with self certificates
app.commandLine.appendSwitch('ignore-certificate-errors');
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
@ -195,6 +192,27 @@ if (shouldQuit) {
return;
}
var allowedURLCertificates = [];
electron.ipcMain.on('allowCertificate', (event, url) => {
allowedURLCertificates.push(require('url').parse(url).host);
});
app.on('certificate-error', function(event, webContents, url, error, certificate, callback) {
if ( allowedURLCertificates.indexOf(require('url').parse(url).host) >= 0 ) {
event.preventDefault();
callback(true);
} else {
callback(false);
electron.dialog.showMessageBox(mainWindow, {
title: 'Certification Error'
,message: 'The service with the following URL has an invalid authority certification.\n\n'+url+'\n\nYou have to remove the service and add it again, enabling the "Trust invalid authority certificates" in the Options.'
,buttons: ['OK']
,type: 'error'
}, function() {
});
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', createWindow);

Loading…
Cancel
Save