如何强制 JavaMailSenderImpl 使用 TLS1.2? [英] How to force JavaMailSenderImpl to use TLS1.2?

查看:39
本文介绍了如何强制 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆