Allow custom TLS options (fix #181)

fork
Nicolas Chambrier 12 years ago
parent 6bd13ac5a6
commit 0b042e0e14

@ -47,7 +47,9 @@ function ImapConnection(options) {
password: options.password || '', password: options.password || '',
host: options.host || 'localhost', host: options.host || 'localhost',
port: options.port || 143, port: options.port || 143,
secure: options.secure || false, secure: options.secure === true ? { // secure = true means default behavior
rejectUnauthorized: false // Force pre-node-0.9.2 behavior
} : (options.secure || false),
connTimeout: options.connTimeout || 10000, // connection timeout in msecs connTimeout: options.connTimeout || 10000, // connection timeout in msecs
xoauth: options.xoauth, xoauth: options.xoauth,
xoauth2: options.xoauth2 xoauth2: options.xoauth2
@ -124,10 +126,15 @@ ImapConnection.prototype.connect = function(loginCb) {
socket.setTimeout(0); socket.setTimeout(0);
if (this._options.secure) { if (this._options.secure) {
var tlsOptions = {};
for (var k in this._options.secure) {
tlsOptions[k] = this._options.secure[k];
}
tlsOptions.socket = state.conn;
if (process.version.indexOf('v0.6.') > -1) if (process.version.indexOf('v0.6.') > -1)
socket = tls.connect(null, { socket: state.conn }, onconnect); socket = tls.connect(null, tlsOptions, onconnect);
else else
socket = tls.connect({ socket: state.conn }, onconnect); socket = tls.connect(tlsOptions, onconnect);
} else } else
state.conn.once('connect', onconnect); state.conn.once('connect', onconnect);

Loading…
Cancel
Save