C#学习教程:我的自定义代理服务器上的SSL(https)错误当我从firefox发送http请求时,它工作正常!但是当我尝试httpsfirefox回复时:连接到mail.yahoo.com时发生错误。SSL收到一条内容类型未知的记录。(错误代码:ssl_error_rx_unknown_record_type)我调试了它成功连接到https并重新接收字节的代码,但是当它传递到它拒绝的套接字时:Tehre是8080上的侦听器,我的代码是:ServicePointManager.ServerCertificateValidationCallback=newSystem.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);System.Net.ServicePointManager.SecurityProtocol=SecurityProtocolType.Ssl3;CookieContainercookie=newCookieContainer();如果(strClientConnection.Contains("443")){strClientConnection="https://"+strClientConnection.Replace(":443","");};HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(strClientConnection);request.CookieContainer=cookie;请求.KeepAlive=真;请求超时=120000;request.AllowAutoRedirect=true;请求.ReadWriteTimeout=120000;request.Method="POST";{使用(HttpWebResponsemyWebResponse=(HttpWebResponse)request.GetResponse()){boolisSuccess=(int)myWebResponse.StatusCode=200;如果(isSuccess){使用(流阅读器=myWebResponse.GetResponseStream()){intBytesRead=0;字节[]缓冲区=新字节[32];int字节发送=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请求(除非它专门用于进行“官方”中间人攻击)HTTP客户端(包括浏览器)使用HTTPCONNECT方法告诉代理服务器将整个HTTPS请求(实际上是SSL/TLS)通过隧道传输到目标HTTPS服务器。当您在代理上收到CONNECT请求时(例如CONNECThost.example.org:443),您应该建立到host.example.org:443的直接TCP连接并将其内容(双向)中继到浏览器而不进行更改。以上就是C#学习教程:SSL(https)erroronmycustomproxyserver的全部内容。不代表立场,如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
