所以我试着用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
不是我的问题所以请停止回答。
发布于 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中。当然,如果您信任提供这些证书的主机,就可以这样做。即通常公司创建其自己的证书以供内部使用。
https://stackoverflow.com/questions/31338015
复制相似问题