Android JavaMail应用程序-CertPathValidatorException:找不到证书路径的信任锚
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Android JavaMail应用程序-CertPathValidatorException:找不到证书路径的信任锚,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1855字,纯文字阅读大概需要3分钟。
内容图文
![Android JavaMail应用程序-CertPathValidatorException:找不到证书路径的信任锚](/upload/InfoBanner/zyjiaocheng/695/3a11a82d3362483b8593863f9e41f7d5.jpg)
请在重复之前,请先阅读我的问题.
使用自签名证书时,我已阅读有关此错误的许多问题和解答.但是,我的问题是,尝试连接到GMAIL imap服务器时出现此错误.所以,我真的需要一些帮助.我的代码是:
private String[] ReadMailbox(String MailboxName) throws IOException {
Properties props = new Properties();
props.setProperty("mail.store.protocol", "imaps");
props.setProperty("mail.imaps.port", "993");
List<String> FromAddressArrList = new ArrayList<String>();
props.setProperty("mail.store.protocol", "imaps");
try {
Session session = Session.getInstance(props, null);
Store store = session.getStore();
store.connect("imap.gmail.com", "username", "password");
ActiveMailbox = store.getFolder(MailboxName);
ActiveMailbox.open(Folder.READ_ONLY);
Message[] messages = ActiveMailbox.getMessages();
for (int i = 0; i < messages.length; i++) {
Message message = messages[i];
Address[] from = message.getFrom();
FromAddressArrList.add(from[0].toString());
}
//ActiveMailbox.close(true);
store.close();
} catch (NoSuchProviderException e) {
FromAddressArrList.add(e.toString());
} catch (MessagingException e) {
FromAddressArrList.add(e.toString());
}
String[] FromAddressArr = new String[FromAddressArrList.size()];
FromAddressArrList.toArray(FromAddressArr);
return FromAddressArr;
}
我收到此错误消息:
javax.mail.MessagingException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.; nested exception is: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
现在,当涉及到自签名证书时,我会发生这种情况,但是为什么在尝试连接到GMAIL时收到此消息?您能帮我使我的应用程序正常工作吗?
解决方法:
可能有防火墙,防病毒或代理程序正在拦截您连接到邮件服务器的请求,并提供其证书而不是Gmail证书.使用InstallCert程序查看它要提供给您的证书.
另一种可能性是信任库为空,丢失或配置不正确,这就是为什么它找不到信任锚的原因.
内容总结
以上是互联网集市为您收集整理的Android JavaMail应用程序-CertPathValidatorException:找不到证书路径的信任锚全部内容,希望文章能够帮你解决Android JavaMail应用程序-CertPathValidatorException:找不到证书路径的信任锚所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。