当前位置:编程学习 > C#/ASP.NET >>

SslStream.AuthenticateAsClient()验证失败

如下是我做的一个读取邮件内容的一段程序,下面是我连接邮箱服务器的一段代码
我连接邮箱服务器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());
                    } --------------------编程问答-------------------- 没人? --------------------编程问答-------------------- --------------------编程问答-------------------- 碰到一样的问题,不知道能不能直接把确认SSL的身份给去掉
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,