4

我有一个 fla(使用 ActionScript 3.0)我在 Flash 中编译。我正在使用 URLRequest 和 URLLoader 访问 http 网络服务。

var loader:URLLoader = new URLLoader();     
var request:URLRequest = new URLRequest("http:test.webservice.com");    
try {
   loader.load(request);
} catch (error:Error) {
   trace("Unable to load requested document.");
}

这很好用 - 但是如果我尝试访问我得到的 https 地址

httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=0]
ioErrorHandler: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: https://test.webservice.com"]

如何从 https 网络服务中检索数据?SWF 是否必须托管在 SSL 安全页面上?

4

2 回答 2

6

如果您安装了 flash 调试播放器,您可能会在日志中看到以下内容:

** Security Sandbox Violation ***
Connection to https://www.example.com/service/ halted - not permitted from http://www.example.com/your.swf

Error: Request for resource at https://www.example.com/service/ by requestor from http://www.example.com/your.swf is denied due to lack of policy file permissions.

默认情况下,托管在 http 中的 swf 无法访问 https——它被视为不同的域。

您需要设置适当的 crossdomain.xml 策略文件,并注意验证 Content-Type 是 text/* 还是其他列入白名单的值。此外,您需要一个带有“secure=false”的元策略文件,这将允许从 http 访问 https。

  <allow-access-from domain="www.example.com" secure="false" />

进一步阅读:

Flash Player 9 和 Flash Player 10 中的策略文件更改

于 2010-09-30T19:04:37.743 回答
2

检查 actionscript 文档中的跨域策略。
http://kb2.adobe.com/cps/142/tn_14213.html

允许访问通过非安全协议托管的电影的安全服务器

不允许 HTTP 内容访问 HTTPS 内容是不可取的。这种做法可能会损害 HTTPS 提供的安全性。

但是,可能存在允许旧 Flash 内容访问 HTTPS 站点的数据的情况。对于 Flash Player 7,默认情况下不再允许这样做。要允许通过 HTTP 提供的 Flash 电影访问 HTTPS 数据,请使用“allow-access-from”标签中的安全属性并将其设置为 false。

 <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">


        <cross-domain-policy>


        <allow-access-from domain="www.company.com" secure="false" />


        </cross-domain-policy> 

它保存为 crossdomain.xml 并放置在 HTTPS 服务器的站点根目录中。

于 2009-11-16T23:54:34.370 回答