net/smtp 是否以纯文本形式发送凭据?
Does net/smtp send credentials in plain text?
我正在看这个例子。 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,即明文形式的 username/password。通常当您使用它时,加密将在较低级别处理,例如您将创建一个 TLS 连接。然后在上面使用 PlainAuth。如果您不是通过加密连接进行通话,那么使用 PlainAuth 可能会有风险,因为如果流量被拦截,user/pass 很容易获得。
但是如果你阅读,你会看到 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 普遍,后者大多数都支持。
我正在看这个例子。 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,即明文形式的 username/password。通常当您使用它时,加密将在较低级别处理,例如您将创建一个 TLS 连接。然后在上面使用 PlainAuth。如果您不是通过加密连接进行通话,那么使用 PlainAuth 可能会有风险,因为如果流量被拦截,user/pass 很容易获得。
但是如果你阅读,你会看到 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 普遍,后者大多数都支持。