我的自定义代理服务器上的SSL(https)错误

这是我的模式代码! 当我从Firefox发送http请求它工作正常! 但当我尝试https firefox回复时:

连接到mail.yahoo.com时发生错误。 SSL收到了内容类型未知的记录。 (错误代码:ssl_error_rx_unknown_record_type)

我调试它成功连接到https的代码并重新接收字节但是当它传递给套接字时它会拒绝:

Tehre是8080的听众,我的代码是:

ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; CookieContainer cookie = new CookieContainer(); if (strClientConnection.Contains("443")) { strClientConnection = "https://" + strClientConnection.Replace(":443",""); }; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strClientConnection); request.CookieContainer = cookie; request.KeepAlive = true; request.Timeout = 120000; request.AllowAutoRedirect = true; request.ReadWriteTimeout = 120000; request.Method = "POST"; { using (HttpWebResponse myWebResponse = (HttpWebResponse)request.GetResponse()) { bool isSuccess = (int)myWebResponse.StatusCode = 200; if (isSuccess) { using (Stream reader = myWebResponse.GetResponseStream()) { int BytesRead = 0; Byte[] Buffer = new Byte[32]; int BytesSent = 0; BytesRead = reader.Read(Buffer, 0, 32); while (BytesRead != 0) { m_sockClient.Send(Buffer, BytesRead, 0); BytesSent += BytesRead; BytesRead = reader.Read(Buffer, 0, 32); } } } } } 

HTTP代理通常不会自己发出HTTPS请求(除非它专门用于进行“官方”Man-In-The-Middle攻击)。

HTTP客户端(包括浏览器)使用HTTP CONNECT方法告诉代理服务器将整个HTTPS请求(实际上是SSL / TLS)隧道转发到目标HTTPS服务器。

当您在代理上收到CONNECT请求时(比如CONNECT host.example.org:443 ),您应该建立到host.example.org:443的直接TCP连接,并将其内容(两种方式)中继到浏览器,而不进行更改。