是什么让这个HTTPS的WebRequest超时,即使它在浏览器?它在、浏览器、HTTPS、WebRequest

2023-09-02 10:30:24 作者:天黑路滑社會真特么複雜

下面是我的要求:

var request = (HttpWebRequest) WebRequest.Create("https://mtgox.com/");
request.CookieContainer = new CookieContainer();
request.AllowAutoRedirect = false;
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
request.Headers[HttpRequestHeader.AcceptEncoding] = "gzip, deflate";
request.Headers[HttpRequestHeader.AcceptLanguage] = "en-gb,en;q=0.5";
request.Headers[HttpRequestHeader.AcceptCharset] = "ISO-8859-1,utf-8;q=0.7,*;q=0.7";
request.Timeout = 5000;
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0";
request.Method = "GET";

request.GetResponse();

标头是从Firefox中使用HttpFox复制。我用Fiddler2来验证,至少对于HTTP请求,标题是Firefox的请求和我的请求之间完全一致。

The headers were copied from Firefox using HttpFox. I used Fiddler2 to verify that at least for HTTP requests, the headers are completely identical between Firefox requests and my requests.

但是,执行请求时的这个特定的网站的使用HTTPS,该请求只是超时。它适用于其他网站。

However, when performing a request to this specific website using HTTPS, the request simply times out. It works for other websites.

我一定是不同的演艺吧到Firefox,因为它始终工作在Firefox浏览器。它使用Fiddler2,然而,因为每当Fiddler2将这些请求转发他们的我无法调试也超时,即使发起的Firefox浏览器。

I must be performing it differently to Firefox, because it always works in Firefox. I can't debug it using Fiddler2, however, because whenever Fiddler2 forwards these requests they also time out, even when originated by Firefox.

难道仅仅是一个真正越野车的网站?其中上述部分给了我走的不是火狐?

Is it just a really buggy website? Which part of the above gives me away as not being Firefox?

推荐答案

使用Microsoft网络监视器,我发现的HttpWebRequest 将得到停留在一个阶段,它应该派备份客户端密钥交换。它根本没有。服务器正式等着它,但它永远不会来了。

Using Microsoft Network Monitor, I found that HttpWebRequest would get stuck at a stage where it's supposed to send back a client key exchange. It simply didn't. The server duly waited for it, but it never came.

什么固定它迫使HttpWebRequest的使用,而不是TLS(即使TLS应该自动转成SSL3如果需要的话)SSL3:

What fixed it was forcing HttpWebRequest to use SSL3 instead of TLS (even though TLS is supposed to automatically turn into SSL3 if necessary):

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

为什么是这样的话我想我永远也不会知道 - 那些神秘的东西,将需要更多的时间来找出比我认识的人只有一个愿意花......

Why this is so I guess I'll never know - just one of those mysterious things that would take more time to figure out than anyone I know is willing to spend...

一件事,是关于捕捉不同:TLS变异有一个警报项中的服务器Hello响应,这是不存在的SSL3交流,也从所有实际工作的TLS交流研究。然而奇怪的是,同样的警告是present在Firefox的捕捉成功执行的请求。

One thing that was different about the captures: the TLS variant had an "Alert" entry in the Server Hello response, which is absent from the SSL3 exchange and also from all the TLS exchanges that actually worked. Curiously, though, the same alert is present in a capture of Firefox performing the request successfully.

最后,似乎有一个临时的OCSP故障只是当我第一次张贴了这个问题,这已经得到了解决。这增加的一塌糊涂,但不是核心问题。

Finally, it appears that there was a temporary OCSP glitch just when I was first posting this question, which has since been resolved. This added to the mess, but isn't the core problem.