SslStream.AuthenticateAsClient()验证失败

world_wolf 2012-03-31 05:27:53
如下是我做的一个读取邮件内容的一段程序,下面是我连接邮箱服务器的一段代码
我连接邮箱服务器serverTcpConnection = new TcpClient(popServer, port);
连接已成功,但我在 ((SslStream)pop3Stream).AuthenticateAsClient(popServer);
验证时一直提示 System.IO.IOException: 由于意外的数据包格式,握手失败。

if (pop3ConnectionState != Pop3ConnectionStateEnum.Disconnected &&
pop3ConnectionState != Pop3ConnectionStateEnum.Closed &&
!isTimeoutReconnect)
{
CallWarning("connect", "", "Connect command received, but connection state is: " + pop3ConnectionState.ToString());
}
else
{
//establish TCP connection
try
{
CallTrace(" Connect at port {0}", port);
serverTcpConnection = new TcpClient(popServer, port);
}
catch (Exception ex)
{
throw new Pop3Exception("Connection to server " + popServer + ", port " + port + " failed.\nRuntime Error: " + ex.ToString());
}

if (useSSL)
{
//get SSL stream
try
{
CallTrace(" Get SSL connection");
pop3Stream = new SslStream(serverTcpConnection.GetStream(), false);
pop3Stream.ReadTimeout = readTimeout;
}
catch (Exception ex)
{
throw new Pop3Exception("Server " + popServer + " found, but cannot get SSL data stream.\nRuntime Error: " + ex.ToString());
}

//perform SSL authentication
try
{
CallTrace(" Get SSL authentication");
((SslStream)pop3Stream).AuthenticateAsClient(popServer);
}
catch (Exception ex)
{
throw new Pop3Exception("Server " + popServer + " found, but problem with SSL Authentication.\nRuntime Error: " + ex.ToString());
}
...全文
608 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lin131 2012-10-31
  • 打赏
  • 举报
回复
碰到一样的问题,不知道能不能直接把确认SSL的身份给去掉
world_wolf 2012-04-01
  • 打赏
  • 举报
回复
没人?

111,076

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧