title: System.IO.IOException: Authentication failed because the remote party has closed the transport stream
body: <p>I'm creating a webservice ( in .NET 3.5) to obtain SSL certificate information of a remote server based on the domain name and i have a client which is a console application to call the service. presently for me there are 11 domain names. i am able to obtain the SSL information for all server except one.</p>
  
  <p>my code is:</p>
  
  <pre><code>    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;
      }    
  </code></pre>
  
  <p>the error is </p>
  
  <blockquote>
    <p><em>"[System.IO.IOException] = {"Authentication failed because the remote
    party has closed the transport stream."}".</em></p>
  </blockquote>
  
  <p>When I examined during debugging at SSLStream I found the error as "</p>
  
  <blockquote>
    <p><em>This operation is only allowed using a successfully authenticated
    context".</em></p>
  </blockquote>
  
  <p>Is that because I don't have enough credentials is it throwing the error or any issues with the service? Also I tried to do Remote desktop conncetion to that server, I'm unable to coonect.</p>