Android的应用程序的JavaMail - CertPathValidatorException:认证路径信任锚未找到 [英] Android JavaMail application - CertPathValidatorException: Trust anchor for certification path not found

查看:458
本文介绍了Android的应用程序的JavaMail - CertPathValidatorException:认证路径信任锚未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请,使之成为一个重复之前,请阅读我的问题。 我一直使用自签名证书时读了很多问题和解答有关这个错误。不过,我的问题是试图连接到Gmail的IMAP服务器时,我得到这个错误。所以,我真的需要一些帮助。我的code是:

Please, before making this a duplicate, read my problem. I have read many questions and answers about this error when using self signed certificates. But, my problem is that I get this error when trying to connect to GMAIL imap server. So, I really need some help. My code is:

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:找不到证书路径信任锚;嵌套例外是:javax.net.ssl​​.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径信任锚

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时此消息?你能帮助我,使我的应用程序的工作?

Now, I now this can happen when there are self signed certificates involved, but why do I get this message when trying to connect to GMAIL? Can you help me to make my application work?

推荐答案

有可能是一个防火墙或防病毒软件或代理程序多数民众赞成拦截您的请求连接到邮件服务器,并提供Gmail的证书,其证书来代替。使用 InstallCert 计划,看看有什么证书,这是presenting给你。

There might be a firewall or anti-virus or proxy program that's intercepting your request to connect to your mail server and providing its certificate instead of the Gmail certificate. Use the InstallCert program to see what certificate it's presenting to you.

另一种可能性是,信任存储为空或丢失,或配置不正确,这就是为什么它找不到信任锚。

Another possibility is that the trust store is empty or missing or incorrectly configured, which is why it can't find the trust anchor.

这篇关于Android的应用程序的JavaMail - CertPathValidatorException:认证路径信任锚未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆