Skip to content

Commit 4b19dee

Browse files
authored
fix(imap-starttls): define SNICallback only when insecure (closes #635) (#637)
1 parent aa60ef9 commit 4b19dee

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

imap-core/lib/imap-server.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,21 +402,17 @@ class IMAPServer extends EventEmitter {
402402
}
403403

404404
if (this.options.secure) {
405-
// appy changes
406-
405+
// apply changes
407406
Object.keys(defaultTlsOptions || {}).forEach(key => {
408407
if (!(key in this.options)) {
409408
this.options[key] = defaultTlsOptions[key];
410409
}
411410
});
412-
413-
// ensure SNICallback method
414-
if (typeof this.options.SNICallback !== 'function') {
415-
// create default SNI handler
416-
this.options.SNICallback = (servername, cb) => {
417-
cb(null, this.secureContext.get(servername));
418-
};
419-
}
411+
} else if (typeof this.options.SNICallback !== 'function') {
412+
// ensure SNICallback method and create default SNI handler
413+
this.options.SNICallback = (servername, cb) => {
414+
cb(null, this.secureContext.get(servername));
415+
};
420416
}
421417
}
422418

0 commit comments

Comments
 (0)