security - net/smtp 是否以纯文本形式发送凭据?

标签 security email go smtp

我正在看这个例子。 http://golang.org/pkg/net/smtp/#example_PlainAuth

package main

import (
    "log"
    "net/smtp"
)

func main() {
    // Set up authentication information.
    auth := smtp.PlainAuth("", "user@example.com", "password", "mail.example.com")

    to := []string{"recipient@example.net"}
    mesg := []byte("This is the email body.")

    err := smtp.SendMail("mail.example.com:25", auth, "sender@example.org", to, mesg)
    if err != nil {
        log.Fatal(err)
    }
}

smtp.PlainAuth 是否以明文形式向邮件服务器发送凭据?在野外使用 net/smtp 安全吗?

最佳答案

PlainAuth 使用来自 RFC 4616 的 Plain auth mech,它是明文形式的用户名/密码。通常当您使用它时,加密将在较低级别处理,例如您将创建一个 TLS 连接。然后在上面使用 PlainAuth。如果您不是通过加密连接进行通话,那么使用 PlainAuth 可能会有风险,因为流量被拦截了,用户/密码很容易获得。

但是如果你阅读,你会看到 SendMail 函数是这样写的:

SendMail connects to the server at addr, switches to TLS if possible, authenticates with the optional mechanism a if possible, and then sends an email from address from, to addresses to, with message msg.

所以它会尝试在可能的情况下自动升级到 TLS。所以只要你使用的是支持 TLS 的服务器,你应该是相对安全的。另一种 Auth 选择是 CramMD5,但服务器对这种方法的支持通常不如 PlainAuth 普遍,而 PlainAuth 大多数都支持。

关于security - net/smtp 是否以纯文本形式发送凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30158027/

相关文章:

android - Pin 代码屏幕电话差距 android

php - IMAP 和 PHP - 从已发送和收件箱文件夹中获取所有电子邮件

google-app-engine - 如何从 appengine.Context 创建云 context.Context

mysql - SHA2(RAND(), 256) 中有多少熵?

php - 阻止访问 php.ini 文件

linux - Linux Debian Wheezy 上的 Sendemail 在 gmail 和 gmx 帐户上出现错误

google-app-engine - 转到 GAE 错误 : can't find '__main__' module (Win 8. 1)

go - 作为服务运行时没有这样的文件或目录?

asp.net-mvc - ASP.NET MVC - WebSecurity 是如何工作的?

javascript - 这是这个正则表达式练习的好解决方案吗?