C# System.IO.IOException:身份验证失败,因为远程方已关闭传输流

C# System.IO.IOException:身份验证失败,因为远程方已关闭传输流,c#,web-services,remote-access,C#,Web Services,Remote Access,我正在创建一个webservice(在.NET3.5中)来获取基于域名的远程服务器的SSL证书信息,我有一个客户端,它是一个控制台应用程序来调用该服务。目前我有11个域名。我能够获得除一台服务器之外的所有服务器的SSL信息 我的代码是: using (TcpClient client = new TcpClient()) { client.Connect(strDNSEntry, 443); SslStream ssl =

我正在创建一个webservice(在.NET3.5中)来获取基于域名的远程服务器的SSL证书信息,我有一个客户端,它是一个控制台应用程序来调用该服务。目前我有11个域名。我能够获得除一台服务器之外的所有服务器的SSL信息

我的代码是:

    using (TcpClient client = new TcpClient())
    {            
        client.Connect(strDNSEntry, 443);

        SslStream ssl = new SslStream(client.GetStream(), false);
        try
        {
            ssl.AuthenticateAsClient(strDNSEntry);    //Error thrown here
        }
        catch (AuthenticationException e)
        {
            log.Debug(e.Message);
            ssl.Close();
            client.Close();
            return cert;
        }
        catch (Exception e)
        {
            log.Debug(e.Message);
            ssl.Close();
            client.Close();
            return cert;
        }
        cert = new X509Certificate2(ssl.RemoteCertificate);
        ssl.Close();
        client.Close();
        return cert;
    }    
错误是

“[System.IO.IOException]={”身份验证失败,因为远程 缔约方已关闭运输流。“}”

当我在SSLStream调试期间检查时,发现错误为“

仅允许使用已成功验证的 上下文”

这是因为我没有足够的凭据吗?是它引发了错误还是服务出现了任何问题?此外,我还尝试与该服务器进行远程桌面连接,但无法连接。

也许您可以使用“Windows Communication Foundation”WCF框架,创建服务类,然后使用SSL传输配置正确配置客户端/服务器TCP绑定参数

如果您尝试这样做,稍后我将给您一个测试用例