【问题标题】:Why Nodemailer does not securely connect to my server running on a shared host为什么 Nodemailer 不能安全地连接到我在共享主机上运行的服务器
【发布时间】:2021-01-22 10:38:43
【问题描述】:

我需要保护我的节点应用程序和我的邮件服务器(在共享主机上运行)之间的连接。 我使用这样配置的 Nodemailer:

{  
   transport: {
     // Is this where I am not sure
      key: [ readFileSync(__dirname + '/../../../../cert.pem') ],
      host: mail.my.domain,
      auth: {
        user: USER,
        pass: PWD
     }
  }
}

当我尝试发送电子邮件时,我遇到了这个错误:

Hostname/IP does not match certificate's altnames: Host: mail.my.domain. is not in the cert's altnames: DNS:xxx.planethoster.net, DNS:xxx.xxx.planethoster.net

我到处都读到我应该使用rejectUnauthorized: true 来绕过这个问题并且它有效。但让这种连接得到保护并不是一种选择。

加载的cert.pem 是我的邮件服务器的私有~/ssl/keys/XXXX.key,使用.pem 扩展名重命名。我对证书/密钥的东西不太满意,但我知道在我的服务器上运行的 SSL 证书是有效的。

所以,我怀疑我重命名并提供给 Nodemailer 的文件。

【问题讨论】:

    标签: node.js ssl tls1.2 nodemailer


    【解决方案1】:

    Planethoster 的支持帮助我了解出了什么问题。我不想让这个在这里,因为我认为我不会是唯一使用共享托管进行邮件的人。

    事实上,我的邮件服务器位于 Planethoster 的共享主机上。因此,证书仅适用于主机名称。这里是world-346.fr.planethoster.net

    所以我通过这样设置我的配置解决了这个问题:

    {  
       transport: {
          // Removed the unecessary cert loading
          // key: [ readFileSync(__dirname + '/../../../../cert.pem') ],
          host: world-346.fr.planethoster.net, // The host is now the shared machine
          auth: {
            user: USER,
            pass: PWD
         }
      }
    }
    

    主机现在可以使用给定的主机名,因为它包含在其证书中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-05
      • 2017-05-22
      • 2016-07-12
      • 1970-01-01
      • 2019-01-18
      • 1970-01-01
      • 2017-12-16
      • 1970-01-01
      相关资源
      最近更新 更多