【问题标题】:IE silently dropping cookies on iframe page (SSL)?IE 在 iframe 页面 (SSL) 上静默放置 cookie?
【发布时间】:2014-12-09 15:51:27
【问题描述】:

我在多域 Web 应用程序中遇到了 iframe 和 cookie 问题。

就在我开始之前,我很清楚 domain1 上的 application1 无法访问或设置 domain2 上 application2 的 cookie。所以这不是初学者的问题。

问题如下:
我有 website1,位于 https://test.xyz-abc.ch/FM_xyz/w8/index.html

和一个报告服务器(website2),位于 https://www8.company-asp.ch/ReportServer

问题的缩小版是这样的:

我把这个内容放了

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Test Page</title>
    </head>

<body>
    <iframe src="www8.company-asp.ch/ReportServer/login.aspx" width="1000" height="1000" ></iframe>
</body>
</html>

使用 URL
https://test.xyz-abc.ch/FM_xyz/w8/ifrm.html 进入文件“ifrm.html”

现在,无论我在报表服务器表单上输入的用户名/密码是什么,它都不起作用(用户名和密码 120% 正确,并且存在并拥有所有必要的权限)。

如果我在 Google Chrome 或 Firefox 上做同样的事情,那么它可以工作,我可以登录 iframe 中包含的报告应用程序。

但在 Internet Explorer 中,您可以(尝试)登录,但始终停留在登录屏幕,因为未知原因,它要么不创建 cookie,要么不发送 cookie。

如果我在 iframe 之外运行报告服务器,我可以登录并在 Internet Exploder 中打开报告。
请注意,ReportServer 在表单身份验证(使用 cookie)上运行,而不是 Windows 身份验证。

另外,问题不是特定于 ReportServer,我可以将任何使用 cookie 进行身份验证的应用程序放在那里,它们也会失败 - 但仅在 Internet Exploder 中,Chrome 和 Firefox 中一切正常。

我觉得这很奇怪,因为 - 如果我在
https://www6.company-asp.ch/FM_xyz/w8/index.html
上运行相同的应用程序 (site1) 并在同一域上拥有报告服务器
https://www8.company-asp.ch/ReportServer
,然后它工作。

有人知道问题是什么或可能是什么(我的意思是除了 IE 是一个 sh*t 软件的事实)?
我唯一能想到的工作变体和非工作变体之间的区别是主域(两个示例中的子域不同)是不同的。

这是 IE 中的(设计使然)SSL 问题(= 严重错误?),或者这可能是 SSL/SSL-Certificate 配置错误的问题?

编辑:
是的,我知道我可以像 &lt;see below&gt; 那样禁用它,但这不是一个可接受的解决方案。我不能告诉客户告诉他的所有员工在他们的 IE 中更改此设置。首先,这永远行不通,其次,他们可能无权更改这些设置,第三,无论出于何种原因,IT 部门可能不允许这样做,第四,因为要求客户更改浏览器的设置是愚蠢的。 .

编辑 2:
情况变得更糟。它是 P3P,我通过 web.config 使用 P3P 标头在我的测试域上工作。
但是不能在 ReportServer 的 web.config 中添加 P3P 头,因为它运行在某种内部 IIS6 上。

【问题讨论】:

标签: internet-explorer iframe ssl cookies forms-authentication


【解决方案1】:

试试这个:

1.打开Internet Explorer,选择工具|互联网选项

2.单击安全选项卡

3.选择互联网区域

4.向下滚动到“在 IFRAME 中启动程序和文件”

5.选择启用

6.点击确定

【讨论】:

  • 太好了,然后它可以在我的计算机上运行,​​但不能在客户上运行;) 如果您将此称为解决方案,请提供一个可以放在执行此操作的基本页面上的零日漏洞利用。实际上,它位于“隐私”->“高级”-->“禁用自动 cookie 处理”
【解决方案2】:

这确实是P3P 的作品。
精湛的 IE 巨魔级别。

The solution:

正常解决此问题的明智方法是将自定义标头添加到 web.config 文件的 system.webServer 部分。

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>


    <httpProtocol>
        <customHeaders>
          <add name="p3p" value="CP=&quot;IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT&quot;"/>
        </customHeaders>
    </httpProtocol>
</system.webServer>

但是,由于 SSRS 非常简单,它们在内部使用 IIS6/Cassini(即使在具有 IIS 7.5 的操作系统上也是如此)。 所以你不能只在 web.config 文件中添加标题,因为 system.webServer 是 IIS7+。

将带有内联标签的标题放入 aspx 页面是不够的,也不起作用

<%
    System.Web.HttpContext.Current.Response.AppendHeader("P3P", "CP=\\\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\\\"");
 %>

因此,您需要编写一个自定义 http-Module,在每个响应中添加 P3P-Header...
这很简单,如果 ASP.NET 不会出现问题并且不会在请求结束之前调用 EndRequest 并且在发送请求后再次调用...

所以这是最终结果:

namespace CustomHttpHeaders
{


    public class CustomHttpHeaderModule : System.Web.IHttpModule
    {


        public void Dispose()
        {
            // CustomHttpHeaders.CustomHttpHeaderModule mod = new CustomHttpHeaderModule();
        }


        public void Init(System.Web.HttpApplication context)
        {
            // context.BeginRequest += new System.EventHandler(context_BeginRequest);
            context.EndRequest += new System.EventHandler(context_EndRequest);
        }


        void context_BeginRequest(object sender, System.EventArgs e)
        {
            if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Request != null)
            {
                System.Web.HttpRequest request = System.Web.HttpContext.Current.Request;
                // request.Headers.Add("name", "value");
            } // End if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Response != null)
        }


        void context_EndRequest(object sender, System.EventArgs e)
        {
            if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Response != null)
            {
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;

                try
                {
                    // OMG - WTF ??? non-redundant redundancy ^3 
                    // response.Headers["P3P"] = "CP=\\\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\\\"":
                    // response.Headers.Set("P3P", "CP=\\\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\\\"");
                    // response.AddHeader("P3P", "CP=\\\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\\\"");
                    response.AppendHeader("P3P", "CP=\\\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\\\"");
                }
                catch(System.Exception ex)
                {
                    // WTF ? 
                    System.Console.WriteLine(ex.Message); // Suppress warning
                }

            } // End if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Response != null)

        } // End Using context_EndRequest


    } // End Class myHTTPHeaderModule


} // End Namespace CustomHttpHeaders

然后你可以在ReportServer的web.config文件中添加CustomHttpHeaderModule。
呜呜呜:O=

  [...]
  <httpModules>
    <clear />
    <add name="CustomHttpHeaders" type="CustomHttpHeaders.CustomHttpHeaderModule, CustomHttpHeaders" />
  </httpModules>

</system.web>

如果你想在 Visual Studio 2013 (IIS Express) 中调试它,你也需要这个(在 web.config 文件中)

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>

<modules runAllManagedModulesForAllRequests="true" >
  <add name="CustomHttpHeaders" type="CustomHttpHeaders.CustomHttpHeaderModule, CustomHttpHeaders" />
</modules>


<!--
<httpProtocol>
  <customHeaders>
      <add name="p3p" value="CP=&quot;IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT&quot;"/>
  </customHeaders>
</httpProtocol>
-->

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-25
    • 2016-07-24
    • 2011-06-09
    • 2011-09-27
    • 1970-01-01
    • 1970-01-01
    • 2020-12-19
    • 1970-01-01
    相关资源
    最近更新 更多