首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Java中使用commons-mail发送电子邮件

在Java中使用commons-mail发送电子邮件
EN

Stack Overflow用户
提问于 2015-07-10 18:03:00
回答 6查看 2.2K关注 0票数 3

所以我试着用Java发送一个代码到我的电子邮件中。我开始使用javax.mail,但记得上次我使用它时遇到了问题,所以我转向了Apache Commons Mail。

不过,我还是收到了一堆错误。在SSL上,我得到一个java.net.SocketTimeoutException在TLS上,我得到了一些错误:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2000)

Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

当我在谷歌上快速搜索时,我发现此question..。现在因为我是个彻头彻尾的笨蛋,我不明白答案。

我能做些什么来解决这些错误?无论是防止SSL上的超时还是TLS上的其他超时。

编辑:我没有问题发送电子邮件和MessageException不是我的问题所以请停止回答。

EN

Stack Overflow用户

发布于 2021-02-25 18:06:14

错误

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

证书链被破坏了。这意味着提供程序可能正在使用客户端系统不信任的自签名证书。可信证书存储在C:\Program Files\Java\jdk1.6.0\jre\lib\security中的cacerts中,如上面的答案所述。

解决此问题的一种方法可能是将缺少的根证书或中间证书添加到cacerts中。当然,如果您信任提供这些证书的主机,就可以这样做。即通常公司创建其自己的证书以供内部使用。

票数 0
EN
查看全部 6 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31338015

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档