简体   繁体   English

Android JavaMail应用程序-CertPathValidatorException:找不到证书路径的信任锚

[英]Android JavaMail application - CertPathValidatorException: Trust anchor for certification path not found

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. 但是,我的问题是,尝试连接到GMAIL imap服务器时出现此错误。 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;
}

And I get this error message: 我收到此错误消息:

javax.mail.MessagingException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.; javax.mail.MessagingException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。 nested exception is: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 嵌套的异常是:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。

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? 现在,当涉及到自签名证书时,我会发生这种情况,但是为什么在尝试连接到GMAIL时收到此消息? Can you help me to make my application work? 您能帮我使我的应用程序正常工作吗?

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. 可能有防火墙,防病毒或代理程序正在拦截您连接到邮件服务器的请求,并提供其证书而不是Gmail证书。 Use the InstallCert program to see what certificate it's presenting to you. 使用InstallCert程序查看要提供给您的证书。

Another possibility is that the trust store is empty or missing or incorrectly configured, which is why it can't find the trust anchor. 另一种可能性是信任库为空,丢失或配置不正确,这就是为什么它找不到信任锚的原因。

禁用Norton Smart Firewall解决问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:CertPathValidatorException:找不到证书路径的信任锚 - Android: CertPathValidatorException: Trust anchor for certification path not found CertPathValidatorException:未找到证书路径的信任锚 - CertPathValidatorException: Trust anchor for certification path not found java.security.cert.CertPathValidatorException:找不到证书路径的信任锚 - java.security.cert.CertPathValidatorException: Trust anchor for certification path not found java.security.cert.CertPathValidatorException:找不到证书路径的信任锚 - java.security.cert.CertPathValidatorException: Trust anchor for certification path not found Android Studio:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚 - Android Studio: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found Android N java.security.cert.CertPathValidatorException:找不到证书路径的信任锚 - Android N java.security.cert.CertPathValidatorException: Trust anchor for certification path not found CertPathValidatorException:在Android中将Fiddler用作代理时未找到证书路径的信任锚 - CertPathValidatorException: Trust anchor for certification path not found when using Fiddler as proxy in Android Android-Retrofit2-java.security.cert.CertPathValidatorException:找不到证书路径的信任锚 - Android - Retrofit2 - java.security.cert.CertPathValidatorException: Trust anchor for certification path not found Hostgator 启用的免费 SSL - Android 错误:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚 - Free SSL Enabled by Hostgator - Android Error : java.security.cert.CertPathValidatorException: Trust anchor for certification path not found android java.security.cert.CertPathValidatorException:找不到证书路径的信任锚 - android java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM