首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Haraka没有授权我的认证

Haraka没有授权我的认证
EN

Stack Overflow用户
提问于 2013-07-26 18:26:10
回答 2查看 2.9K关注 0票数 2

我正在构建一个需要tls认证的应用程序。我使用以下命令生成了.pem文件tls_cert.pem和tls_key.pem

代码语言:javascript
复制
openssl req -x509 -nodes -days 2190 -newkey rsa:1024 -keyout config/tls_key.pem -out config/tls_cert.pem

就像Haraka建议的那样,并确保Common字段的内容与我的config/me文件的内容相同。在我的配置/插件中

代码语言:javascript
复制
# 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

javascript/fooBar是我用coffeescript编写的一个自定义插件,它被编译成一个js文件,这意味着它映射到plugins/javascript/Mx25Out1244 Actions.js。

以下是plugins/javascript/fooBar.js的内容

代码语言:javascript
复制
(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 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
          if (user === results[i].address && 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);

我在运行它时遇到了问题。Haraka启动得很好,但是当我运行命令时

代码语言:javascript
复制
swaks -f test@test.com -t myemail@gmail.com -s localhost -p 587 -au testname -ap t3$tPassword

在另一个议会里,我从斯瓦克斯那里得到了一个错误

代码语言:javascript
复制
*** Host did not advertise authentication

原坂的产量看起来就像

代码语言:javascript
复制
[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

我在这迷路了。我已经浏览了Haraka关于这个主题的所有文档,以及我找到的源代码和几个示例项目。为什么Haraka不授权我的认证?

编辑

我有认证代码。我一开始没有包括它,因为我不认为它与错误相关。即使包含了它,Haraka输出也完全相同,函数第一行中的this.loginfo调用也不会出现。Swaks产生的误差和输出也完全相同。在我把它包括进去之后,还是读了马特的书。为了重复检查,我还试着注释掉exports.check_plain_passwd中的所有代码,并在所有情况下只返回cb(true)。什么都没变。我得到了同样的输出和同样的错误。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-07-29 16:16:30

您想要尝试的第一件事是在调用-tls时使用swaks。在服务器日志中,我看到它广告的是STARTTLS (而不是广告AUTH),但是客户机立即退出,而不是协商TLS。如果真的有问题,那就是瞒着你。

票数 3
EN

Stack Overflow用户

发布于 2013-07-27 19:37:22

看起来您是在添加身份验证,而不是TLS --为此您需要一个auth插件,比如auth/ plugin。另外,根据TLS文档,它应该首先列在config/plugins文件中(使用auth/平面_ file第二)-插件顺序很重要-它决定了运行的顺序,并且您希望TLS是发生的第一件事情。

这里有关于auth_flat_file的文档:file.html

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17888450

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档