首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用imap xoauth获取电子邮件

如何使用imap xoauth获取电子邮件
EN

Stack Overflow用户
提问于 2012-08-03 22:27:07
回答 1查看 879关注 0票数 2

如何通过使用xoauth验证imap来从gmail中检索邮件。我已经尝试过Gmail data api for xoauthAuthenticator.java,xoauthprotocol.java,xoauthsaslclient.java和xoauthsaslclienfactory.java的代码

但是我得到了像这样的错误

代码语言:javascript
复制
Exception in thread "main" javax.mail.MessagingException: Remote host closed connection during handshake;
  nested exception is:
    javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
    at javax.mail.Service.connect(Service.java:275)
    at XoauthAuthenticator.connectToImap(XoauthAuthenticator.java:80)
    at XoauthAuthenticator.main(XoauthAuthenticator.java:114)
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
    at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
    at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at com.sun.mail.iap.ResponseInputStream.read0(ResponseInputStream.java:81)
    at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:67)
    at com.sun.mail.iap.Response.<init>(Response.java:83)
    at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:48)
    at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:122)
    at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:230)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:91)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
    ... 3 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
    ... 19 more

这是什么原因呢?

EN

回答 1

Stack Overflow用户

发布于 2012-08-04 01:02:06

当您的SSLhandler不信任来自主机服务器的证书时,将抛出SSLHandshakeException。您需要将服务器的SSL证书添加到密钥库。Here is a good walk through of the problem以及如何修复它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11797676

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档