【问题标题】:Android JavaMail application - CertPathValidatorException: Trust anchor for certification path not foundAndroid JavaMail 应用程序 - CertPathValidatorException:找不到证书路径的信任锚
【发布时间】:2014-12-15 17:18:32
【问题描述】:

请在复制之前阅读我的问题。 在使用自签名证书时,我已经阅读了许多关于此错误的问题和答案。但是,我的问题是在尝试连接到 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:找不到证书路径的信任锚。;嵌套异常是:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。

现在,当涉及到自签名证书时,我现在可能会发生这种情况,但是为什么我在尝试连接到 GMAIL 时会收到此消息?你能帮我完成我的应用程序吗?

【问题讨论】:

    标签: android ssl jakarta-mail imap


    【解决方案1】:

    禁用诺顿智能防火墙解决了问题

    【讨论】:

      【解决方案2】:

      可能有防火墙、防病毒或代理程序拦截了您连接到邮件服务器的请求并提供其证书而不是 Gmail 证书。使用InstallCert 程序查看它向您提供的证书。

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

      【讨论】:

      • 你是对的! Avast Antivirus 阻止了我的应用程序,尽管我不明白为什么。禁用它解决了问题!
      猜你喜欢
      • 2015-05-30
      • 2017-10-03
      • 2021-03-18
      • 1970-01-01
      • 1970-01-01
      • 2015-04-17
      • 2017-01-08
      • 2019-02-24
      相关资源
      最近更新 更多