使用fiddler和Windows身份验证

Pie*_*ant 22 c# windows-authentication fiddler

我正在为我们的应用程序测试一些代理设置,但我需要测试需要Windows身份验证(或网络凭据)的代理.

为了进行测试,我将代理的凭据分配给网络凭据

System.Net.WebProxy proxy = new System.Net.WebProxy("127.0.0.1", 8888);
proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
//proxy.Credentials = new System.Net.NetworkCredential("1", "1");
System.Net.WebRequest.DefaultWebProxy = proxy;
Run Code Online (Sandbox Code Playgroud)

目前,我使用Fiddler Require Proxy Authentication打开规则.如何配置Fiddler以便我可以使用Windows凭据而不是默认的"1"/"1"凭据?

Eiv*_*eth 37

在Fiddler 4.6中,我可以在Composer - > Options下打开"Automatically Authenticate".然后成功调用使用Windows身份验证在IIS中托管的WebAPI.您可以在日志中看到三个请求进行单个呼叫.

  1. HTTP/1.1 401 Unauthorized Cache-Control: private Content-Type: text/html; charset=utf-8 Server: Microsoft-IIS/10.0 WWW-Authenticate: Negotiate WWW-Authenticate: NTLM

  2. HTTP/1.1 401 Unauthorized Content-Type: text/html; charset=us-ascii Server: Microsoft-HTTPAPI/2.0 WWW-Authenticate: Negotiate oYIBDTCCAQ... Date: Mon, 18 Jan 2016 09:38:22 GMT Content-Length: 341

  3. HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/10.0 X-AspNet-Version: 4.0.30319 Persistent-Auth: true WWW-Authenticate: Negotiate oRsw... Date: Mon, 18 Jan 2016 09:38:22 GMT Content-Length: 4


Eri*_*Law 6

Fiddler你不能轻易做到这一点; 您需要自己计算凭证质询,并在使用Proxy-Authenticate:Negotiate标头返回HTTP/407响应后在响应标头中添加质询.

相比之下,单个响应头很容易支持BASIC身份验证,这就是Fiddler的"需要代理身份验证"功能的工作原理.