Note that there are some explanatory texts on larger screens.

plurals
  1. POHaraka not authorizing my authentication
    text
    copied!<p>I'm building an application in Haraka that requires tls certification. I generated the .pem files tls_cert.pem and tls_key.pem using the command </p> <pre><code>openssl req -x509 -nodes -days 2190 -newkey rsa:1024 -keyout config/tls_key.pem -out config/tls_cert.pem </code></pre> <p>like Haraka suggests and making sure that the contents of the Common Name field is the same as the contents of my config/me file. In my config/plugins I have</p> <pre><code># default list of plugins # Log to syslog (disabled by default, see docs) #log.syslog # block mails from known bad hosts (see config/dnsbl.zones for the DNS zones queried) #dnsbl # Check mail headers are valid data.rfc5322_header_checks # block mail from some known bad HELOs - see config/helo.checks.ini for configuration #helo.checks # control which "MAIL FROM" addresses you accept. See docs. #mail_from.access # Only accept mail where the MAIL FROM domain is resolvable to an MX record #mail_from.is_resolvable # Disconnect client if they spew bad SMTP commands at us #max_unrecognized_commands # control which "RCPT TO" addresses you reject. See docs. #rcpt_to.access # Only accept mail for your personal list of hosts. Edit config/host_list # NOTE: THIS IS REQUIRED for inbound email. rcpt_to.in_host_list # Queue mail via smtp - see config/smtp_forward.ini for where your mail goes #queue/smtp_forward ##### Custom Plugins #### javascript/fooBar tls </code></pre> <p>javascript/fooBar is a custom plugin that I wrote in coffeescript and compiled into a js file meaning it maps to plugins/javascript/Mx25OutBoundActions.js</p> <p>Here are the contents of plugins/javascript/fooBar.js</p> <pre><code>(function() { var DataBase, Password, User, database; DataBase = require('./dataBase'); database = new DataBase(); User = null; Password = null; exports.hook_lookup_rdns = function(next, conn) { return next(OK, ''); }; exports.hook_connect = function(next, conn, params) { conn.remote_host = ''; return next(CONT, "The MX25 SMTP API is now ready."); }; exports.register = function() { this.loginfo('Test'); return this.inherits('auth/auth_base'); }; exports.hook_capablities = function(next, conn) { var methods; this.loginfo('Hello'); conn.capabilities.push('STARTTLS'); conn.notes.tls_enabled = 1; if (conn.using_tls) { this.loginfo('Connection Secure'); methods = ['PLAIN', 'LOGIN']; conn.capabilities.push("AUTH " + (methods.join(' '))); conn.notes.allowed_auth_methods = methods; return next(); } else { this.loginfo('Connection not secure'); return next(DENY, '5.7.1 Secure connection required'); } }; exports.get_plain_passwd = function(user, cb) { this.loginfo('*********'); this.loginfo(user); this.loginfo('*********'); return cb(user); }; exports.check_plain_passwd = function(conn, user, passwd, cb) { this.loginfo("Hello!"); database.query('SELECT * FROM domains', function(error, results) { var Password, User, flag, i, _i, _ref; if (error == null) { flag = 0; for (i = _i = 0, _ref = results.length; 0 &lt;= _ref ? _i &lt;= _ref : _i &gt;= _ref; i = 0 &lt;= _ref ? ++_i : --_i) { if (user === results[i].address &amp;&amp; passwd === results[i].outbound_password) { flag = 1; break; } } if (flag === 1) { User = user; Password = passwd; return cb(true); } else { console.log('User not authenticated'); return next(DENY, '5.7.1 Invalid authentication credentials provided'); } } else { console.log("Error: ${error}."); } }); return cb(true); }; });.call(this); </code></pre> <p>I run into problems when I run it. Haraka starts up just fine but when I run the command</p> <pre><code>swaks -f test@test.com -t myemail@gmail.com -s localhost -p 587 -au testname -ap t3$tPassword </code></pre> <p>In another council I get an error from swaks saying</p> <pre><code>*** Host did not advertise authentication </code></pre> <p>And the output of Haraka looks like </p> <pre><code>[NOTICE] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] connect ip=::1 port=64243 local_ip=:: local_port=587 [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running lookup_rdns hooks [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running lookup_rdns hook in javascript/fooBar plugin [INFO] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] hook=lookup_rdns plugin=javascript/fooBar function=hook_lookup_rdns params="" retval=OK msg="" [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running connect hooks [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running connect hook in javascript/fooBar plugin [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] hook=connect plugin=javascript/fooBar function=hook_connect params="" retval=CONT msg="The MX25 SMTP API is now ready." [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] S: 220 The MX25 SMTP API is now ready. [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] C: EHLO richardas-mac-mini.local state=1 [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running ehlo hooks [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running capabilities hooks [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running capabilities hook in javascript/fooBar plugin [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] hook=capabilities plugin=javascript/fooBar function=hook_capabilities params="" retval=CONT msg="" [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running capabilities hook in tls plugin [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] hook=capabilities plugin=tls function=hook_capabilities params="" retval=CONT msg="" [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] S: 250-outbound.mx25.net Hello [::1], Haraka is at your service. [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] S: 250-PIPELINING [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] S: 250-8BITMIME [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] S: 250-SIZE 500000 [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] S: 250 STARTTLS [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] C: QUIT state=1 [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running quit hooks [PROTOCOL] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] S: 221 outbound.mx25.net closing connection. Have a jolly good day. [DEBUG] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] running disconnect hooks [NOTICE] [3D27FD1C-B94A-4271-84EB-460B32598491] [core] disconnect ip=::1 rdns="" helo="richardas-mac-mini.local" relay=N early=N esmtp=Y tls=N pipe=N txns=0 rcpts=0/0/0 msgs=0/0/0 bytes=0 lr="" time=0.008 </code></pre> <p>I'm at a lost here. I've scoured every bit of documentation Haraka has on this subject as well as the source code and a couple sample projects that I found. Why won't Haraka authorize my authentication?</p> <p><strong>Edit</strong></p> <p>I have code for authentication. I didn't include it initially because I didn't think it was relevant to the error. Even with it included the Haraka output is exactly the same and this.loginfo call in the first line of the function doesn't appear. The error and output produced by Swaks is also exactly the same. Still after reading Matt's after I have included it. To double check this I also tried commenting out all the code in exports.check_plain_passwd and just returned cb(true) in all cases. Nothing changed. I got the same output and the same errors.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload