【问题标题】:Security error when trying access remote data from swf尝试从 swf 访问远程数据时出现安全错误
【发布时间】:2011-06-15 15:37:09
【问题描述】:

我在域 http://domain1.com/myroot/ 的 swf 应用程序必须使用来自域 http://domain2.com/myroot2/ 的资源

当 swf 试图从二级域访问资源时,它得到 SecurityError:

错误 #2048:违反安全沙箱。

这似乎是因为我的应用程序默认尝试加载 crossdomain.xml(来自 http://domain2.com/crossdomain.xml)。

我的问题是我无权访问 domain2.com 根目录来将文件 crossdomain.xml 放在那里。我只能放在 http://domain2.com/myroot2/ 目录下。

我的问题是:如何强制我的 swf 应用程序在 http://domain2.com/myroot2/ 中搜索 crossdomain.xml?

附: Security.loadPolicyFile("http://domain2.com/myroot2/crossdomain.xml") 不起作用,因为默认使用元策略“master-only”,这使得忽略所有 Security.loadPolicyFile 用法。

【问题讨论】:

    标签: actionscript-3 security crossdomain.xml


    【解决方案1】:

    Flash 的新沙盒安全性要求您始终在服务器的根目录上拥有一个跨域策略文件。如果您要将跨域文件放在子目录中,根的主跨域文件必须在服务器上允许。

    【讨论】:

    【解决方案2】:

    loadPolicyFile 应该这样做

    Security.allowDomain( 'http://domain2.com' );
    Security.loadPolicyFile( 'http://domain2.com/myroot2/pf.xml' );
    

    【讨论】:

      猜你喜欢
      • 2015-04-10
      • 2016-06-27
      • 2012-06-07
      • 2021-08-05
      • 2011-01-19
      • 1970-01-01
      • 2019-10-23
      • 1970-01-01
      • 2016-04-19
      相关资源
      最近更新 更多