无法在Apache Commons Mail上将套接字转换为TLS

时间:2016-07-11 15:28:02

标签: java email javamail apache-commons apache-commons-email

使用Apache Commons Mail连接到SMTP服务器时遇到问题。我尝试了一切,但我在网上找到的唯一的东西是Java Mail。 这是我的错误:

  

引起:javax.mail.MessagingException:无法将套接字转换为TLS;     嵌套异常是:       javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到所请求目标的有效证书路径

我已经看到你可以使用props.put("mail.smtp.ssl.trust", "smtp.gmail.com");修复Java Mail上的问题,但是我不能在Apache Commons上使用相同的命令。

1 个答案:

答案 0 :(得分:2)

If you're really connecting to Gmail, you shouldn't need that. The Gmail certificate will be trusted by the default trust store. If you've configured a non-default trust store, add the Gmail certificate to that trust store using the InstallCert program.

相关问题