简体   繁体   English

AS3 LoadPolicyFile函数也适用于远程swfs吗?

[英]Does the AS3 LoadPolicyFile function apply to remote swfs as well?

I have a swf one one server that is pulling content from an Amazon S3 server. 我有一个swf一对一服务器,该服务器正在从Amazon S3服务器提取内容。 I have set up, for now, a generic cross-domain policy to allow all domains access: 我现在已经设置了通用的跨域策略,以允许所有域访问:

On the server containing the swf: 在包含swf的服务器上:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE cross-domain-policy SYSTEM
  "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-access-from domain="*" />
</cross-domain-policy>

On the S3 server: 在S3服务器上:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE cross-domain-policy SYSTEM
  "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="master-only" />
  <allow-access-from domain="*" />
  <allow-http-request-headers-from domain="*" 
    headers="SOAPAction" />
</cross-domain-policy>

These seem to be playing nicely (for the most part) as my swf is loading json, xml, etc. files from the S3 server just fine now. 由于我的瑞士法郎正在从S3服务器加载json,xml等文件,因此这些文件在大多数情况下似乎运行得很好。 What it's not doing right is loading swfs from the S3 server, when it tries to do that it throws this exception: 正确的做法是从S3服务器加载swfs,当它尝试这样做时会引发以下异常:

SecurityError: Error #2121: Security sandbox violation: Loader.content: s3.amazonaws.com/bucket_name/swfs/foo.swf cannot access s3.amazonaws.com/bucket_name/data/swfs/bar.swf. SecurityError:错误#2121:违反安全沙箱:Loader.content:s3.amazonaws.com/bucket_name/swfs/foo.swf无法访问s3.amazonaws.com/bucket_name/data/swfs/bar.swf。 This may be worked around by calling Security.allowDomain. 可以通过调用Security.allowDomain解决此问题。

I assume this is because remote swfs could contain malicious executable code. 我认为这是因为远程swfs可能包含恶意可执行代码。 Do I actually need to set the allowDomain to something or is there some other 'more correct' way of allowing my swf to load up other remote swfs? 我是否真的需要将allowDomain设置为某种值,或者是否有其他“更正确”的方式允许我的swf加载其他远程swf?

Make sure you're using the bucket name as the subdomain for both the Policy file loading, and every file / URL request. 确保您将存储桶名称用作策略文件加载以及每个文件/ URL请求的子域。

Solution: 解:

http://onegiantmedia.com/cross-domain-policy-issues-with-flash-loading-remote-data-from-amazon-s3-cloud-storage http://onegiantmedia.com/cross-domain-policy-issues-with-flash-loading-remote-data-from-amazon-s3-cloud-storage

I've answered a similar question here: 我在这里回答了类似的问题:

https://stackoverflow.com/a/9547996/579230 https://stackoverflow.com/a/9547996/579230

In addition, if your crossdomain.xml is in place, you can just do loaderContext.checkPolicyFile = true instead of loading the file explicitly. 另外,如果您的crossdomain.xml就位,则只需执行loaderContext.checkPolicyFile = true而不是显式加载文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM