Can a SWF (using URLLoader) access HTTPS webservice?Flash能发起Https请求的条件。

jackxiang 2014-5-22 11:59 | |
老外写了个AS3的库支持ssl的https:https://code.google.com/p/as3httpclientlib/downloads/list

I have a fla (using ActionScript 3.0) I am compiling in Flash. I am using URLRequest and URLLoader to access a http webservice.
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.");
}

This works fine - however if I try and access a https address I get

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"]

How can I retrieve data from a https web service? Does the SWF have to be hosted on a SSL secured page?

If you install the flash debug player, you'll probably see the following in the log:
** 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.
By default a swf hosted in a http cannot access https --it's considered a different domain.

You'll need to set up the appropriate crossdomain.xml policy file, with care to verify the Content-Type is text/* or another whitelisted value. Additionally, you'll need a meta-policy file with "secure=false", which will allow https to be accessed from http.



来自:http://stackoverflow.com/questions/1387608/can-a-swf-using-urlloader-access-https-webservice
参考:http://hi.baidu.com/badzzzz/item/47b59cbe7d939e911846977b

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/7210/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2014-5-22 16:41
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]