Python urllib2 HTTPS 和代理 NTLM 身份验证
一般来说,urllib2 似乎不支持带有代理身份验证的 HTTPS,更不用说 NTLM 身份验证了。任何人都知道是否有针对具有 NTLM 身份验证的代理上的 HTTPS 的补丁。
问候,
洛朗
urllib2 doesn't seem to support HTTPS with proxy authentication in general, even less with NTLM authentication. Anyone knows if there is a patch somewhere for HTTPS on proxy with NTLM authentication.
Regards,
Laurent
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
迟回复。 Urllib2 不支持 NTLM 代理,但 pycurl 支持。摘抄:
Late reply. Urllib2 does not support NTLM proxying but pycurl does. Excerpt:
http://code.google.com/p/python-ntlm/
我从未尝试过 HTTPS,但我认为它应该可以工作。
编辑:如果您使用 SSL 隧道,代理身份验证是一个坏主意。
当 SSL 通过隧道传输时,通过 HTTPS 使用基本身份验证的代理并不安全。您的密码将以明文形式(Base64 编码)发送给代理。许多人认为密码将在 SSL 内加密。在这种情况下,情况并非如此。
支持其他加密或散列机制(例如 Digest/NTLM)几乎是不可能的,因为它们都需要协商(多次交换),而 CONNECT 协议中未定义这一点。此协商发生在 HTTP 连接的范围之外。在代理/浏览器中也很难实现。
如果这是企业代理,IP ACL 是唯一安全的解决方案。
http://code.google.com/p/python-ntlm/
I never tried with HTTPS but I think it should work.
EDIT: If you are using SSL Tunneling, proxy authentication is a bad idea.
Proxy using Basic Auth over HTTPS is not secure when the SSL is tunneled. Your password will be sent in clear (Base64-encoded) to proxy. Lots of people assumes the password will be encrypted inside SSL. It's not true in this case.
It's almost impossible to support other encrypted or hashed mechanisms like Digest/NTLM because they all require negotiation (multiple exchanges) and that's not defined in CONNECT protocol. This negotiation happens out of the band of the HTTP connection. It's very hard to implement in proxy/browser also.
If this is an enterprise proxy, IP ACL is the only secure solution.
很好的配方(适用于带有代理的 HTTPS)和讨论这里,应该可以融合@ZZ 已经建议使用 python-nltm 代码。
Good recipe (for HTTPS w/proxy) and discussion here, it should be possible to meld that with the python-nltm code @ZZ has already suggested.