From 0e6fd6968064e813c025d4f45f5c7487b32460a3 Mon Sep 17 00:00:00 2001 From: Chris Brame Date: Sat, 18 Sep 2021 23:33:34 -0400 Subject: [PATCH] fix(mailcheck): added option for less secure certs in mailcheck PR#434 by @hkpanchani --- .../Settings/Mailer/mailerCheck.jsx | 27 +++++++++++++++++++ src/mailer/mailCheck.js | 11 +++++++- src/settings/settingsUtil.js | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/client/containers/Settings/Mailer/mailerCheck.jsx b/src/client/containers/Settings/Mailer/mailerCheck.jsx index fe791e863..cb655b950 100644 --- a/src/client/containers/Settings/Mailer/mailerCheck.jsx +++ b/src/client/containers/Settings/Mailer/mailerCheck.jsx @@ -35,6 +35,7 @@ class Mailer_MailerCheck extends React.Component { mailerCheckPort: '', mailerCheckUsername: '', mailerCheckPassword: '', + mailerCheckSelfSign: '', mailerCheckPolling: '', mailerCheckCreateAccount: '', mailerCheckDeleteMessage: '', @@ -65,6 +66,8 @@ class Mailer_MailerCheck extends React.Component { stateObj.mailerCheckUsername = nextProps.settings.getIn(['settings', 'mailerCheckUsername', 'value']) || '' if (!state.mailerCheckPassword) stateObj.mailerCheckPassword = nextProps.settings.getIn(['settings', 'mailerCheckPassword', 'value']) || '' + if (state.mailerCheckSelfSign === '') + stateObj.mailerCheckSelfSign = nextProps.settings.getIn(['settings', 'mailerCheckSelfSign', 'value']) || '' if (state.mailerCheckPolling === '') stateObj.mailerCheckPolling = parseInt(nextProps.settings.getIn(['settings', 'mailerCheckPolling', 'value'])) / 60000 || '' @@ -124,6 +127,7 @@ class Mailer_MailerCheck extends React.Component { { name: 'mailer:check:port', value: this.state.mailerCheckPort }, { name: 'mailer:check:username', value: this.state.mailerCheckUsername }, { name: 'mailer:check:password', value: this.state.mailerCheckPassword }, + { name: 'mailer:check:selfsign', value: this.state.mailerCheckSelfSign }, { name: 'mailer:check:ticketype', value: this.state.mailerCheckTicketType }, { name: 'mailer:check:ticketpriority', value: this.state.mailerCheckTicketPriority }, { name: 'mailer:check:createaccount', value: this.state.mailerCheckCreateAccount }, @@ -270,6 +274,29 @@ class Mailer_MailerCheck extends React.Component { disabled={!this.getSetting('mailerCheckEnabled')} /> +
+
+
+ Allow Self Signed Certificate +
+
+ Allow less secure self signed certificates when checking mailbox. +
+
+
+ this.onCheckboxChanged(e, 'mailerCheckSelfSign')} + disabled={!this.getSetting('mailerCheckEnabled')} + /> +
+
+
diff --git a/src/mailer/mailCheck.js b/src/mailer/mailCheck.js index 1ab9e4b2b..187c58f87 100644 --- a/src/mailer/mailCheck.js +++ b/src/mailer/mailCheck.js @@ -46,6 +46,9 @@ mailCheck.init = function (settings) { s.mailerCheckPassword = _.find(settings, function (x) { return x.name === 'mailer:check:password' }) + s.mailerCheckSelfSign = _.find(settings, function (x) { + return x.name === 'mailer:check:selfsign' + }) s.mailerCheckPolling = _.find(settings, function (x) { return x.name === 'mailer:check:polling' }) @@ -67,6 +70,7 @@ mailCheck.init = function (settings) { s.mailerCheckPort = s.mailerCheckPort === undefined ? { value: 143 } : s.mailerCheckPort s.mailerCheckUsername = s.mailerCheckUsername === undefined ? { value: '' } : s.mailerCheckUsername s.mailerCheckPassword = s.mailerCheckPassword === undefined ? { value: '' } : s.mailerCheckPassword + s.mailerCheckSelfSign = s.mailerCheckSelfSign === undefined ? { value: false } : s.mailerCheckSelfSign s.mailerCheckPolling = s.mailerCheckPolling === undefined ? { value: 600000 } : s.mailerCheckPolling // 10 min s.mailerCheckTicketType = s.mailerCheckTicketType === undefined ? { value: 'Issue' } : s.mailerCheckTicketType s.mailerCheckTicketPriority = s.mailerCheckTicketPriority === undefined ? { value: '' } : s.mailerCheckTicketPriority @@ -79,16 +83,21 @@ mailCheck.init = function (settings) { var MAILERCHECK_PASS = s.mailerCheckPassword.value var MAILERCHECK_PORT = s.mailerCheckPort.value var MAILERCHECK_TLS = s.mailerCheckPort.value === '993' + var MAILERCHECK_SELFSIGN = s.mailerCheckSelfSign.value var POLLING_INTERVAL = s.mailerCheckPolling.value if (!MAILERCHECK_ENABLED) return true + var tlsOptions = {} + if (MAILERCHECK_SELFSIGN) tlsOptions = { rejectUnauthorized: false } + mailCheck.Imap = new Imap({ user: MAILERCHECK_USER, password: MAILERCHECK_PASS, host: MAILERCHECK_HOST, port: MAILERCHECK_PORT, - tls: MAILERCHECK_TLS + tls: MAILERCHECK_TLS, + tlsOptions: tlsOptions }) mailCheck.fetchMailOptions = { diff --git a/src/settings/settingsUtil.js b/src/settings/settingsUtil.js index 318e6f652..39edfee34 100644 --- a/src/settings/settingsUtil.js +++ b/src/settings/settingsUtil.js @@ -95,6 +95,7 @@ util.getSettings = function (callback) { s.mailerCheckPort = parseSetting(settings, 'mailer:check:port', 143) s.mailerCheckUsername = parseSetting(settings, 'mailer:check:username', '') s.mailerCheckPassword = parseSetting(settings, 'mailer:check:password', '') + s.mailerCheckSelfSign = parseSetting(settings, 'mailer:check:selfsign', false) s.mailerCheckTicketType = parseSetting(settings, 'mailer:check:ticketype', '') s.mailerCheckTicketPriority = parseSetting(settings, 'mailer:check:ticketpriority', '') s.mailerCheckCreateAccount = parseSetting(settings, 'mailer:check:createaccount', false)