Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javamail java.security.cert.CertPathValidator从pop3接收邮件时发生异常_Java_Android_Ssl_Jakarta Mail_Pop3 - Fatal编程技术网

Javamail java.security.cert.CertPathValidator从pop3接收邮件时发生异常

Javamail java.security.cert.CertPathValidator从pop3接收邮件时发生异常,java,android,ssl,jakarta-mail,pop3,Java,Android,Ssl,Jakarta Mail,Pop3,因此,我正在尝试构建一个Android应用程序,它可以检查来自我大学服务器的电子邮件。它与Gmail配合使用效果很好。 我已将证书(.cer文件)添加到密钥库,并尝试使用以下属性: Properties properties = new Properties(); properties.put("mail.store.protocol", "pop3"); properties.put("mail.pop3.host", pop3Host);

因此,我正在尝试构建一个Android应用程序,它可以检查来自我大学服务器的电子邮件。它与Gmail配合使用效果很好。 我已将证书(.cer文件)添加到密钥库,并尝试使用以下属性:

        Properties properties = new Properties();
        properties.put("mail.store.protocol", "pop3");
        properties.put("mail.pop3.host", pop3Host);
        properties.put("mail.pop3.port", "995");
        properties.put("mail.pop3.starttls.enable", "true");
        properties.put("mail.pop3.ssl.checkserveridentity", "false");
        properties.put("mail.pop3.ssl.trust", "*");
        Session emailSession = Session.getDefaultInstance(properties);  
…什么都没有:(

调试:

stefan.studmail I/System.out﹕ DEBUG: setDebug: JavaMail version 1.5.3
stefan.studmail I/System.out﹕ DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle]
stefan.studmail W/art﹕ Before Android 4.1, method javax.mail.Session com.sun.mail.pop3.POP3Store.getSession() would have incorrectly overridden the package-private method in javax.mail.Service
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.rsetbeforequit: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.disabletop: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.forgettopheaders: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.cachewriteto: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.filecache.enable: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.keepmessagecontent: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.starttls.enable: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.starttls.required: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.apop.enable: false
stefan.studmail I/System.out﹕ DEBUG POP3: mail.pop3s.disablecapa: false
stefan.studmail I/System.out﹕ DEBUG POP3: connecting to host "stud.usv.ro", port 995, isSSL true
stefan.studmail I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@37e721f4 time:14882263
stefan.studmail E/StudMail:﹕ Connect failed
stefan.studmail W/System.err﹕ javax.mail.MessagingException: Connect failed;
stefan.studmail W/System.err﹕ nested exception is:
stefan.studmail W/System.err﹕ javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
stefan.studmail W/System.err﹕ at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:213)
stefan.studmail W/System.err﹕ at javax.mail.Service.connect(Service.java:364)
stefan.studmail W/System.err﹕ at javax.mail.Service.connect(Service.java:245)
stefan.studmail W/System.err﹕ at senegeac.stefan.studmail.FetchPop.fetch(FetchPop.java:75)
stefan.studmail W/System.err﹕ at senegeac.stefan.studmail.FetchPop.doInBackground(FetchPop.java:145)
stefan.studmail W/System.err﹕ at senegeac.stefan.studmail.FetchPop.doInBackground(FetchPop.java:39)
stefan.studmail W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:297)
stefan.studmail W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
stefan.studmail W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
stefan.studmail W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
stefan.studmail W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
stefan.studmail W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
stefan.studmail W/System.err﹕ Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
stefan.studmail W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:306)
stefan.studmail W/System.err﹕ at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:574)
stefan.studmail W/System.err﹕ at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:369)
stefan.studmail W/System.err﹕ at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
stefan.studmail W/System.err﹕ at com.sun.mail.pop3.Protocol.<init>(Protocol.java:112)
stefan.studmail W/System.err﹕ at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:264)
stefan.studmail W/System.err﹕ at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:207)
stefan.studmail W/System.err﹕ ... 11 more
stefan.studmail W/System.err﹕ Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
stefan.studmail W/System.err﹕ at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:323)
stefan.studmail W/System.err﹕ at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:224)
stefan.studmail W/System.err﹕ at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:113)
stefan.studmail W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:525)
stefan.studmail W/System.err﹕ at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
stefan.studmail W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:302)
stefan.studmail W/System.err﹕ ... 17 more
stefan.studmail W/System.err﹕ Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
stefan.studmail W/System.err﹕ ... 23 more
stefan.studmail I/System.out﹕ 调试:setDebug:JavaMail版本1.5.3
stefan.studmail I/System.out﹕ 调试:getProvider()返回javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.pop3sslsstore,Oracle]
stefan.studmail W/art﹕ 在Android 4.1之前,javax.mail.Session com.sun.mail.pop3.POP3Store.getSession()方法会错误地覆盖javax.mail.Service中的包私有方法
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.rsetBeforeRequirement:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.disabletop:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.遗忘者:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.cachewriteto:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.filecache.enable:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.keepmessagecontent:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.starttls.enable:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.starttls.required:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.apop.enable:false
stefan.studmail I/System.out﹕ 调试POP3:mail.pop3s.disablecapa:false
stefan.studmail I/System.out﹕ 调试POP3:连接到主机“stud.usv.ro”,端口995,isSSL true
stefan.studmail I/Timeline﹕ 时间线:Activity\u idle id:android.os。BinderProxy@37e721f4时间:14882263
stefan.studmail电子邮件/studmail:﹕ 连接失败
stefan.studmail W/System.err﹕ javax.mail.MessaginException:连接失败;
stefan.studmail W/System.err﹕ 嵌套异常是:
stefan.studmail W/System.err﹕ javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚点。
stefan.studmail W/System.err﹕ 在com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:213)上
stefan.studmail W/System.err﹕ 在javax.mail.Service.connect(Service.java:364)
stefan.studmail W/System.err﹕ 在javax.mail.Service.connect(Service.java:245)
stefan.studmail W/System.err﹕ 位于senegeac.stefan.studmail.FetchPop.fetch(FetchPop.java:75)
stefan.studmail W/System.err﹕ 位于senegeac.stefan.studmail.FetchPop.doInBackground(FetchPop.java:145)
stefan.studmail W/System.err﹕ 位于senegeac.stefan.studmail.FetchPop.doInBackground(FetchPop.java:39)
stefan.studmail W/System.err﹕ 在android.os.AsyncTask$2.call(AsyncTask.java:297)
stefan.studmail W/System.err﹕ 位于java.util.concurrent.FutureTask.run(FutureTask.java:237)
stefan.studmail W/System.err﹕ 在android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
stefan.studmail W/System.err﹕ 位于java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
stefan.studmail W/System.err﹕ 位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
stefan.studmail W/System.err﹕ 运行(Thread.java:818)
stefan.studmail W/System.err﹕ 原因:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidator异常:找不到证书路径的信任锚。
stefan.studmail W/System.err﹕ 访问com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:306)
stefan.studmail W/System.err﹕ 位于com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:574)
stefan.studmail W/System.err﹕ 在com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:369)上
stefan.studmail W/System.err﹕ 位于com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
stefan.studmail W/System.err﹕ 位于com.sun.mail.pop3.Protocol.(Protocol.java:112)
stefan.studmail W/System.err﹕ 位于com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:264)
stefan.studmail W/System.err﹕ 在com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:207)上
stefan.studmail W/System.err﹕ ... 还有11个
stefan.studmail W/System.err﹕ 原因:java.security.cert.CertificateException:java.security.cert.CertPathValidator异常:找不到证书路径的信任锚。
stefan.studmail W/System.err﹕ 位于com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:323)
stefan.studmail W/System.err﹕ 位于com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:224)
stefan.studmail W/System.err﹕ 位于com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:113)
stefan.studmail W/System.err﹕ 访问com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateCain(OpenSSLSocketImpl.java:525)
stefan.studmail W/System.err﹕ 在com.android.org.conscrypt.NativeCrypto.SSL_do_握手(本机方法)
stefan.studmail W/System.err﹕ 访问com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:302)
stefan.studmail W/System.err﹕ ... 还有17个
stefan.studmail W/System.err﹕ 原因:java.security.cert.CertPathValidator异常:找不到证书路径的信任锚点。
stefan.studmail W/System.err﹕ ... 23多
尝试使用


如果这不起作用,请发布用getInstance尝试过的。

但没有。添加了调试日志,并尝试在属性中将pop3更改为pop3,但在调试中仍然显示false。您认为您正在将“mail.pop3s.starttls.enable”属性设置为“true”,但调试输出清楚地表明它是错误的。您仍然在做一些错误的事情,但从您向我们展示的内容来看,我无法判断它是什么。