使用 TLS 连接通过 SMTP 发送电子邮件会加密用户名和密码吗?
does sending email via SMTP with TLS connection encrypt the username and password?
我用 Java 编写了一个应用程序来发送电子邮件。为了发送电子邮件,我使用了 SMTP
和 TLS
。
最近我搜索了有关 TLS 的内容,并在 this website 上找到了有关 TLS 的流畅描述:Transport Layer Security (TLS), a protocol that encrypts and delivers mail securely, helps prevent eavesdropping and spoofing (message forgery) between mail servers.
上面的短语说 TLS 保证邮件将被安全传递,但它没有说任何关于密码的事情...
假设我在我的应用程序中使用了以下代码,如您所见,您需要对用户名和密码进行硬编码,而无需任何加密。
final String username = "...@hotmail.com";
final String password = "your Password";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp-mail.outlook.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
通过使用此策略,TLS 是否会在从我的服务器发送到另一台服务器时加密我的密码?我应该担心还是不担心?
密码传输和通讯加密是两个不同的事情
TLS 是通过发出 STARTTLS 命令在最初未加密的通道上启动的;如果服务器支持,则交换完成,完成后,通道被加密。
然后才开始 SMTP 协商;如果有的话,这个谈判的一部分是认证。即使您使用简单的身份验证机制(用户和密码按原样通过网络发送),由于当时通道已加密,窃听者也不会清楚地看到它。
当然,为了更安全,您可以选择使用 另一种 验证机制而不是普通验证机制(例如 CRAM-MD5;其他存在)。
编辑 好的,上面的答案只是部分准确;可以在 this excellent answer on ServerFault by @Bruno
中找到更多详细信息
我用 Java 编写了一个应用程序来发送电子邮件。为了发送电子邮件,我使用了 SMTP
和 TLS
。
最近我搜索了有关 TLS 的内容,并在 this website 上找到了有关 TLS 的流畅描述:Transport Layer Security (TLS), a protocol that encrypts and delivers mail securely, helps prevent eavesdropping and spoofing (message forgery) between mail servers.
上面的短语说 TLS 保证邮件将被安全传递,但它没有说任何关于密码的事情...
假设我在我的应用程序中使用了以下代码,如您所见,您需要对用户名和密码进行硬编码,而无需任何加密。
final String username = "...@hotmail.com";
final String password = "your Password";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp-mail.outlook.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
通过使用此策略,TLS 是否会在从我的服务器发送到另一台服务器时加密我的密码?我应该担心还是不担心?
密码传输和通讯加密是两个不同的事情
TLS 是通过发出 STARTTLS 命令在最初未加密的通道上启动的;如果服务器支持,则交换完成,完成后,通道被加密。
然后才开始 SMTP 协商;如果有的话,这个谈判的一部分是认证。即使您使用简单的身份验证机制(用户和密码按原样通过网络发送),由于当时通道已加密,窃听者也不会清楚地看到它。
当然,为了更安全,您可以选择使用 另一种 验证机制而不是普通验证机制(例如 CRAM-MD5;其他存在)。
编辑 好的,上面的答案只是部分准确;可以在 this excellent answer on ServerFault by @Bruno
中找到更多详细信息