在开发一个开源代理脚本时,一段代码如下: static void Main(string[] args) { string host = "www.google.com"; int proxyPort = 443;//443;
byte[] buffer = new byte[2048];
int bytes;
// Connect socket
TcpClient client = new TcpClient(host, proxyPort);
NetworkStream stream = client.GetStream();
byte[] tunnelRequest = Encoding.UTF8.GetBytes(String.Format("CONNECT www.google.com:443 HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.1; rv:23.0) Gecko/20100101 Firefox/23.0\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nHost: www.google.com\r\n\r\n", host));
stream.Write(tunnelRequest, 0, tunnelRequest.Length);
stream.Flush();
SslStream sslStream = new SslStream(stream);
sslStream.AuthenticateAsClient(host);
}
当我运行代码时,在这一行发生错误: sslStream.AuthenticateAsClient(host); 错误的解释是:无法从传输连接中读取数据。现有连接被远程主机强行关闭。或此错误:验证失败,因为远程方已关闭传输流。请帮帮我谢谢