【问题标题】:System.IO.IOException: Authentication failed because the remote party has closed the transport streamSystem.IO.IOException:身份验证失败,因为远程方已关闭传输流
【发布时间】:2013-03-24 17:37:41
【问题描述】:

我正在创建一个 Web 服务(在 .NET 3.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 调试期间检查时,我发现错误为“

此操作只允许使用成功的身份验证 上下文”。

是不是因为我没有足够的凭据而引发错误或服务有任何问题?我还尝试对该服务器进行远程桌面连接,但无法连接。

【问题讨论】:

    标签: c# web-services remote-access


    【解决方案1】:

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

    如果你尝试这样做,我稍后会给你一个测试用例。

    【讨论】:

      猜你喜欢
      • 2015-08-20
      • 1970-01-01
      • 2017-08-18
      • 2022-06-29
      • 1970-01-01
      • 2017-02-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多