From 4b19dee20b740f9636ab6a06f1379a4fe5f433fb Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Mon, 26 Feb 2024 01:15:06 -0600 Subject: [PATCH] fix(imap-starttls): define `SNICallback` only when insecure (closes #635) (#637) --- imap-core/lib/imap-server.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/imap-core/lib/imap-server.js b/imap-core/lib/imap-server.js index 095125fa..da204c63 100644 --- a/imap-core/lib/imap-server.js +++ b/imap-core/lib/imap-server.js @@ -402,21 +402,17 @@ class IMAPServer extends EventEmitter { } if (this.options.secure) { - // appy changes - + // apply changes Object.keys(defaultTlsOptions || {}).forEach(key => { if (!(key in this.options)) { this.options[key] = defaultTlsOptions[key]; } }); - - // ensure SNICallback method - if (typeof this.options.SNICallback !== 'function') { - // create default SNI handler - this.options.SNICallback = (servername, cb) => { - cb(null, this.secureContext.get(servername)); - }; - } + } else if (typeof this.options.SNICallback !== 'function') { + // ensure SNICallback method and create default SNI handler + this.options.SNICallback = (servername, cb) => { + cb(null, this.secureContext.get(servername)); + }; } }