407 需要身份验证 - 未发送质询 [英] 407 Authentication required - no challenge sent

查看:26
本文介绍了407 需要身份验证 - 未发送质询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:
如果您刚遇到这个问题,一般要点是我正在尝试通过代理创建 HttpWebRequest,并且我从我们奇怪的代理服务器收到了 407.IE、Firefox、Chrome 都设法成功协商代理,Adobe Air 应用程序也是如此.Google Chrome 网络安装程序实际上失败可能很重要,我们必须使用离线安装程序.

Update:
If you've just arrived at this question, the general gist is that I'm trying to make a HttpWebRequest via a proxy, and I'm getting a 407 from our strange proxy server. IE,Firefox,Chrome all manage to negotiate the proxy sucessfully, as do Adobe Air applications. It may be important that the Google Chrome web installer actually fails and we have to use an offline installer.

多亏了 Ian 的链接,我才能进入下一阶段.它现在将令牌发送回代理,但是第三阶段没有通过,因此 .NET 没有发送带有用户名/密码哈希的请求,因此没有返回 HTML.

Thanks to Ian's link I've got it getting through to the next stage. It is now sending a token back to the proxy, however the 3rd stage isn't getting through, so the request with the username/password hash isn't being sent by .NET and consequently no HTML is returned.

我正在使用:

  • IE6 用户代理
  • Windows 7
  • Scansafe 代理
  • .NET 3.5

这是等同于以下日志的最新代码:

Here's the latest code that equates to the logs below:

HttpWebRequest request = HttpWebRequest.Create("http://www.yahoo.com") as HttpWebRequest;
IWebProxy proxy = request.Proxy;
// Print the Proxy Url to the console.
if (proxy != null)
{
    // Use the default credentials of the logged on user.
    proxy.Credentials = CredentialCache.DefaultCredentials;
}
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
request.Accept = "*/*";

HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream stream = response.GetResponseStream();

异常

WebException (407) 需要身份验证.

WebException (407) Authentication Required.

正在使用的代理

代理客户端是我们服务器机房中的 Scansafe 硬件设备,它(一旦通过NTLM)然后将您的 HTTP 流量定向到其服务器以过滤流量.

The proxy being used

The proxy client is a Scansafe hardware device in our server room, which (once authenticated with NTLM) then directs your HTTP traffic to its servers to filter the traffic.

我还没有真正找到解决方案,但多亏了 Feroze 和 Eric,我找到了一个解决方法,并发现实际的代理(而不是其配置)是主要问题.这可能是 3 个变量的模糊问题:.NET HttpWebRequest 的实现、Windows 7,当然还有我们机架中的 Scansafe 硬件客户端;但如果没有 MSDN 支持请求,我将无法找到.

I haven't really found a solution but thanks to Feroze and Eric I have found a workaround and discovered that the actual proxy (and not its configuration) is the main issue. It may be an obscure issue with 3 variables: .NET HttpWebRequest's implementation, Windows 7 and of course the Scansafe hardware client that sits in our rack; but without an MSDN support request I won't find out.

推荐答案

如果要为代理设置凭据,是不是应该在 request.Proxy 对象而不是 request 对象上设置凭据?

If you want to set credentials for the proxy, shouldn't you set credentials on the request.Proxy object rather than the request object?

http://msdn.microsoft.com/en-us/library/system.net.webproxy.credentials.aspx

另外,请记住,您需要发出 HTTP/1.1 请求(或从技术上讲,任何带有 Keep-Alive 的请求)才能成功使用 NTLM/协商身份验证.

Also, keep in mind that you need to be making a HTTP/1.1 request (or technically, any request with Keep-Alive) to successfully use NTLM/Negotiate authentication.

(Fiddler 的Auth"检查器会为您分解 NTLM 身份验证 blob,如果您还没有看过它.)

(Fiddler's "Auth" inspector will decompose the NTLM authentication blobs for you, if you haven't taken a look at that yet.)

这篇关于407 需要身份验证 - 未发送质询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆