gpt4 book ai didi

asp.net - 代理背后的安全表单例份验证

转载 作者:太空宇宙 更新时间:2023-11-03 12:52:08 25 4
gpt4 key购买 nike

我们在负载均衡器上使用 Stunnel(去除 SSL)和 HAProxy - 然后通过 HTTP 向 IIS 发送请求。

我们遇到的问题是我们希望我们的站点 (ASP.NET) 以安全的方式设置 cookie - 即通过将 requireSSL 属性设置为 true。

当我们设置此属性并向站点发出 HTTPS 请求时,我们收到此错误:

The application is configured to issue secure cookies. These cookies require the browser to issue the request over SSL (https protocol). However, the current request is not over SSL.

如果请求是通过 SSL 从负载均衡器发出的,是否可以信任网络服务器?或者这不是问题,因为只能通过 SSL 访问我们的网站(只有 443 是开放的)?

最佳答案

取而代之的是:

FormsAuthentication.SetAuthCookie(email, false);

试试这个:

var cookie = FormsAuthentication.GetAuthCookie(email, false);
cookie.Secure = true;
HttpContext.Current.Response.Cookies.Add(cookie);

如果您使用的是 ASP.NET MVC,您还可以使用全局操作过滤器,它会在响应中的所有 cookie 上设置安全标志

关于asp.net - 代理背后的安全表单例份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6377134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com