Skip to content

Commit

Permalink
Allow TLS authentication failures (mostly untrusted certs etc.); alwa…
Browse files Browse the repository at this point in the history
…ys restart with an EHLO after TLS connection start
  • Loading branch information
andris9 committed Jul 21, 2011
1 parent b280006 commit 47dbc2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions lib/smtp.js
Expand Up @@ -507,11 +507,10 @@ SMTPClient.prototype._handshakeListener = function(data, callback){
}

/**
* smtp.SMTPClient#_handshakeListener(data) -> undefined
* - data(String): String received from the server
* smtp.SMTPClient#_starttlsHandler(callback) -> undefined
* - callback (Function): Function to be run after connection
*
* Server data listener for the handshake - waits for the 220 response
* from the server (connection established).
* Initiates a TLS session with the server
**/
SMTPClient.prototype._starttlsHandler = function(callback){
if(this.debug){
Expand All @@ -526,18 +525,18 @@ SMTPClient.prototype._starttlsHandler = function(callback){
this.ignore_data = true;
var ssl_socket;
ssl_socket = starttls(this._connection, this.options, (function(){

if(this.debug && !ssl_socket.authorized){
console.log("▒▒▒ WARNING: TLS ERROR ("+ssl_socket.authorizationError+") ▒▒▒");
}

ssl_socket.on("data",this._onData);
this._connection.removeListener("data",this._onData);
this._connection = ssl_socket;
this.ignore_data = false;
this._data_remainder = "";
this.emit("connection_stable");
if(!this._connection.authorized && this.options.use_authentication) {
callback();
}
else{
this._loginHandler(callback);
}
callback();
}).bind(this));
}).bind(this));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/starttls.js
Expand Up @@ -21,7 +21,7 @@ module.exports = function starttls(socket, options, cb) {
cleartext = pipe(pair, socket);

pair.on('secure', function() {
var verifyError = !pair._ssl || pair._ssl.verifyError();
var verifyError = (pair._ssl || pair.ssl).verifyError();

if (verifyError) {
cleartext.authorized = false;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "nodemailer",
"description": "Easy to use module to send e-mails, supports unicode and SSL/TLS",
"version": "0.1.18",
"version": "0.1.19",
"author" : "Andris Reinman",
"maintainers":[
{
Expand Down

0 comments on commit 47dbc2d

Please sign in to comment.