Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SSL:找不到请求目标的有效证书路径_Java_Jsp_Gmail_Jakarta Mail - Fatal编程技术网

Java SSL:找不到请求目标的有效证书路径

Java SSL:找不到请求目标的有效证书路径,java,jsp,gmail,jakarta-mail,Java,Jsp,Gmail,Jakarta Mail,我在发送邮件时遇到以下错误 javax.mail.MessaginException:异常读取响应;嵌套异常为:javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径生成失败:sun.security.provider.certpath.SunCertPathBuilderException:找不到请求目标的有效证书路径 试试这个 String to="mydaman7291@gma

我在发送邮件时遇到以下错误

javax.mail.MessaginException:异常读取响应;嵌套异常为:javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径生成失败:sun.security.provider.certpath.SunCertPathBuilderException:找不到请求目标的有效证书路径

试试这个

String to="mydaman7291@gmail.com";//change accordingly

//Get the session object
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
        "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");

Session sess = Session.getInstance(props,
 new javax.mail.Authenticator() {
 protected PasswordAuthentication getPasswordAuthentication() {
 return new PasswordAuthentication("daman.bonnie07@gmail.com","password");//change accordingly
 }
});

//compose message
try {
 MimeMessage message = new MimeMessage(sess);
 message.setFrom(new InternetAddress("daman.bonnie07@gmail.com"));//change accordingly
 message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
 message.setSubject("Hello");
 message.setText("Testing.......");

 //send message
 Transport.send(message);

 System.out.println("message sent successfully");

} 
catch (MessagingException e) {
    out.println(e);}

添加属性
props.put(“mail.pop3s.ssl.trust”、“*”)并检查。不,我仍然得到相同的例外,如果你用谷歌搜索错误消息,你会发现几十(数百)次点击。您必须向Java密钥库添加适当的CA证书。看,我现在得到了这个错误,javax.mail.MessaginException:Exception reading response;嵌套异常是:javax.net.ssl.SSLException:无法识别的ssl消息,纯文本连接?请有人帮忙?
Properties props = new Properties();
    props.put("mail.smtp.host", "smtp.xyz.in");
    props.put("mail.smtp.socketFactory.port", "25");

    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.port", "25");
    props.put("mail.smtp.dsn.notify",
              "SUCCESS ORCPT=rfc822;");
    props.put("mail.smtp.dsn.ret", "FULL");