问题描述
当我尝试使用javamail连接到gmail POP3服务器时遇到一些麻烦。
我的错误是:
javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到到请求目标的有效证书路径
它在store.connect行处阻塞。
这是我的代码:
System.setProperty("javax.net.ssl.trustStore","C:\\Program Files (x86)\\Java\\jre1.8.0_66\\lib\\security\\cacerts");
Properties prop = System.getProperties();
prop.put("mail.pop3.socketFactory.class","javax.net.ssl.SSLSocketFactory");
prop.put("mail.pop3.socketFactory.fallback","false");
prop.put("mail.pop3.socketFactory.port","995");
prop.put("mail.pop3.port","995");
prop.put("mail.pop3.host","pop.gmail.com");
prop.put("mail.pop3.user",username);
prop.put("mail.store.protocol","pop3");
sess = Session.getInstance(prop,new javax.mail.Authenticator() {
protected PasswordAuthentication getpasswordAuthentication() {
return new PasswordAuthentication(username,pwd);
}
});
System.out.println("Obtention d'un objet store");
st = sess.getStore("pop3");
st.connect(host,username,pwd); //Blocking HERE
我检查了路径,没关系,所以我不明白是什么问题。
谢谢您的帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)