Skip to content

Commit

Permalink
fix(imap-starttls): define SNICallback only when insecure (closes #635
Browse files Browse the repository at this point in the history
) (#637)
  • Loading branch information
titanism authored Feb 26, 2024
1 parent aa60ef9 commit 4b19dee
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions imap-core/lib/imap-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
}
}

Expand Down

0 comments on commit 4b19dee

Please sign in to comment.