发送电子邮件时遇到以下错误 - java 6 tomcat 6

时间:2015-05-12 08:56:45

标签: java tomcat

javax.mail.MessagingException: Exception reading response; nested exception is:
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

1 个答案:

答案 0 :(得分:1)

由于许多原因,可能会发生

javax.mail.MessagingException 。由于您尚未发布任何代码,因此几乎无法正确说出导致此问题的原因。

查看错误的第二部分" PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到所请求目标的有效证书路径"

现在我不能100%肯定地说,但最有可能这些错误与证书有关。即很可能您的Java运行时不信任证书。

通常,Java通过标准信任链机制验证证书。但是如果该链终止于Java不信任的证书,那么Java将以上述方式抱怨。

The solution if this is the case would be to 

1. Download the certificate from the remote SMTP server

2. Import the certificate into your local truststore

有关这些的详细信息,请访问以下链接

http://springinpractice.com/2012/04/29/fixing-pkix-path-building-issues-when-using-javamail-and-smtp

另请查看以下链接

Error in JavaMail : PKIX path building failed unable to find valid certification path to requested target

how to ignore server cert error in javamail

How to solve an error: unable to find valid certification path to requested target error in Java?