大网数据广告活动
服务器运维问答

Is it permissible for an intermediate proxy to add cookies during proxy authentication?

· 52CE 我爱测

I recently encountered a certain security appliance (BlueCoat) which requires that all connections to the internet must be proxied through it (hello there, man-in-the-middle) and accordingly uses a special SSL certificate to inte…

问题原文

原帖链接 · Patrick · CC BY-SA 3.0

I recently encountered a certain security appliance (BlueCoat) which requires that all connections to the internet must be proxied through it (hello there, man-in-the-middle) and accordingly uses a special SSL certificate to intercept all traffic.

This prevented the normal operation of Git, even though the appropriate http.proxy and http.sslCAInfo properties were set to make sure that the SSL connection itself works.

Using the environment variable GIT_CURL_VERBOSE=1, we found that when using git clone, a HTTP 407 (Proxy authentication required) occurs. Git fulfils this authentication properly and at the end of this, the appliance returns a HTTP 200 with a cookie header Set-Cookie.

Git then will connect to the target server, but without the cookie, leading to a HTTP 401.

The solution for this is to set the git configuration option http.saveCookies=true

Question: Is it actually permitted by the RFC standards that an intermediate proxy adds cookies?

Anthony Rich asked the same question to the http-state mailing list but without any response. He did note that in

RFC 2965 HTTP State Management Mechanism, 3.5 Caching Proxy Role it says: Proxies MUST NOT introduce Set-Cookie2 (Cookie) headers of their own in proxy responses (requests).

However, the superseding RFC 6265 doesn't mention this anymore at all.

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

HTTP cookies are a hot mess. There is no real standard; the RFC, for what it's worth, merely attempts to document what actual user agents are doing.

In any case, the RFC you probably want to read is RFC 7235, which specifies that proxies are supposed to send a Proxy-Authenticate header with the 407 status to request authentication information, and user agents receiving this are supposed to retry the request with a Proxy-Authorization header containing the authentication information for the proxy.

A number of challenge/response methods could be used to supply this information; the most widely used being "basic" (RFC 7617) as pretty much everything that speaks HTTP implements it.

The IANA maintains a registry of known HTTP authentication schemes. As a general rule they use the HTTP headers named previously, or they are noted to be noncompliant. None use cookies for authentication.

Whether it's allowed for a proxy to add or change cookies, I can't say. The RFCs really don't seem to be very clear on this point. It's certainly unexpected behavior, especially for authentication. And BlueCoat has a long history of being mediocre in quality...

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。