gpt4 book ai didi

c# - Fiddler 和 .Net 3.5 SSL 错误。在 .Net 4.0 中工作正常

转载 作者:太空宇宙 更新时间:2023-11-03 14:58:42 25 4
gpt4 key购买 nike

首先,网站和帖子。

https://saplic.receita.pb.gov.br/sintegra/SINf_ConsultaSintegra.jsp填写字段CNPJ,值为例如34151100004209。

在 Chrome 和 .Net 4.0 Httpwebrequest 中运行良好。但我无法在 fiddler 中进行调试,也无法使其在 .Net 3.5 上运行

我已经在用了

System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(customXertificateValidation);
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
System.Net.ServicePointManager.Expect100Continue = false;

这让我发疯。任何帮助将不胜感激为了让事情更清楚,我有一个问题发生在 2 个不同的地方(Fiddler 和 .net 3.5)

我尝试运行的代码是。

    CookieContainer CookCon =  new CookieContainer();
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("http://sintegra.receita.pb.gov.br/sintegra/sintegra.asp?estado=pb");
Request.Timeout = Configuration.TimeOut;
Request.Proxy = Configuration.Proxy;
Request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36";
Request.Headers.Add("Accept-Encoding", "gzip, deflate");
Request.CookieContainer = new CookieContainer();
using (HttpWebResponse Response = Request.GetResponse() as HttpWebResponse)
{
foreach (Cookie C in Response.Cookies)
{
CookCon.Add(C);
}
Response.Close();
}

HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://saplic.receita.pb.gov.br/sintegra/");
Request.Referer = "http://sintegra.receita.pb.gov.br/sintegra/sintegra.asp?estado=pb";
Request.Headers.Add("X-DevTools-Emulate-Network-Conditions-Client-Id", "C5E5561B-11F5-4D9E-A9D4-54A18E660D11");
Request.CookieContainer = CookCon;
Request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
Request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.103 Safari/537.36";

string HTML = "";

string Encoding = "ISO-8859-1";
Request.Timeout = 20000;

Request.Headers.Add("Accept-Encoding", "gzip, deflate");
using (HttpWebResponse Response = Request.GetResponse() as HttpWebResponse)
{
Stream S = Response.GetResponseStream();
if (Response.ContentEncoding.ToLower().Contains("gzip"))
{
S = new GZipStream(S, CompressionMode.Decompress);
using (System.IO.StreamReader ResStream = new StreamReader(S, System.Text.Encoding.GetEncoding(Encoding)))
{
HTML = ResStream.ReadToEnd();
ResStream.Close();
}
}
else if (Response.ContentEncoding.ToLower().Contains("deflate"))
{
S = new DeflateStream(S, CompressionMode.Decompress);
using (System.IO.StreamReader ResStream = new StreamReader(S, System.Text.Encoding.GetEncoding(Encoding)))
{
HTML = ResStream.ReadToEnd();
ResStream.Close();
}
}
else
{
using (System.IO.StreamReader ResStream = new StreamReader(Response.GetResponseStream(), System.Text.Encoding.GetEncoding(Encoding)))
{
HTML = ResStream.ReadToEnd();
ResStream.Close();
}
}
S.Close();
S.Dispose();
Response.Close();
}

我遇到的错误是当我尝试发帖时出现“unexpeted EOF”异常(上面代码的 GetResponse 部分)。如果我尝试在打开 Fiddler 的情况下在 Chrome 上浏览网站,它不会向北返回,只是保持保持、保持、保持,什么也没有。

如果我将相同的代码复制到一个新的 4.0 项目中,它可以毫无问题地运行。如果不清楚,请提出疑问,我尽量说清楚。

最佳答案

由于没有人提供帮助,我只是使用 .net 4.0 框架制作了一个网络服务,并从 3.5 应用程序调用它。

仍然不知道为什么会发生这种情况..

关于c# - Fiddler 和 .Net 3.5 SSL 错误。在 .Net 4.0 中工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25766926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com