How to force JavaMailSenderImpl to use TLS1.2?(如何强制 JavaMailSenderImpl 使用 TLS1.2?)
问题描述
有一个在 Tomcat 上运行的 JDK7 应用程序,它确实具有以下环境设置:
Have a JDK7 app running on Tomcat and it does have the following env settings:
-Dhttps.protocols=TLSv1.1,TLSv1.2
上述设置确保我们在通过 HTTPS 连接时不使用 TLS 1.0,同时进行 API 调用等.
The above setting ensures that we don't use TLS 1.0 when connecting over HTTPS while making API calls etc.
我们还使用 org.springframework.mail.javamail.JavaMailSenderImpl 类来发送外发 SMTP 电子邮件,并使用这些道具:
We also use the org.springframework.mail.javamail.JavaMailSenderImpl class to send outgoing SMTP email, and use these props:
mail.smtp.auth=false;mail.smtp.socketFactory.port=2525;mail.smtp.socketFactory.fallback=true;mail.smtp.starttls.enable=true
问题在于升级到 TLS1.2 时与 SMTP 电子邮件服务器的连接失败.
The problem is that the connection to the SMTP email server is failing when it's upgraded to TLS1.2.
javax.net.ssl.SSLHandshakeException:远程主机关闭连接握手时
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
是否存在强制使用 TLS1.2 协议的设置或代码更改?
我做了一些搜索,看起来这些环境设置仅适用于小程序和 Web 客户端,不适用于服务器端应用程序
I did some searching and it looks like these env settings are only for applet and web clients, not for server side apps
-Ddeployment.security.SSLv2Hello=false -Ddeployment.security.SSLv3=false -Ddeployment.security.TLSv1=false
推荐答案
这是下一个要找的人的解决方法:
This is the fix for the next guy looking:
mail.smtp.starttls.enable=true;
mail.smtp.ssl.protocols=TLSv1.2;
这篇关于如何强制 JavaMailSenderImpl 使用 TLS1.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何强制 JavaMailSenderImpl 使用 TLS1.2?


- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01