通过flex安全的Web套接字连接会生成安全沙箱冲突

时间:2013-07-11 17:29:19

标签: flex websocket

我正在尝试使用flex连接到安全的Web套接字(wss://),并且我收到了安全沙箱viloation错误。

完整的错误消息如下:

*** Security Sandbox Violation ***
Connection to foo.bar:8443 halted - not permitted from https://foo.bar:8443/foo/foo-html/Main.swf
Security Error: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: https://foo.bar.com:8443/foo/foo-html/Main.swf cannot load data from come2play.xpogames.com:8443."]

连接失败:错误#2048:安全沙箱违规:https://foo.bar.com:8443/foo/bar-html/Main.swf无法从foo.bar.com:8443加载数据。 Websocket已关闭。

我尝试使用的浏览器是FireFox 20.0.1。

我创建了一个javascript客户端,使用端口wss://上的8443协议连接到同一个地址,并且连接正常。

我在tomcat的ROOT目录下包含了一个crossdomain.xml文件,因此flex应用程序可以加载它。 crossdomain.xml文件的内容如下:

<?xml version="1.0"?>
<cross-domain-policy>
    <allow-access-from domain="*" secure="false" />
        <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

我用firebug检查过并注意到crossdomain.xml文件已正确加载。

我尝试使用

手动指定crossdomain.xml文件的位置
flash.system.Security.loadPolicyFile("{Url to my crossdomain.xml file on the SSL virtual root}"); 

但我得到了相同的结果。

我还尝试了这个crossdomain.xml中的不同配置变体。例如secure="yes",我试图指定使用的端口,但没有任何效果,我总是遇到安全沙箱违规。

我知道mms.cfg文件可能已启用DisableSockets = 1指令但我的系统中没有这样的文件。我在Linux Gentoo上。

有趣的是,我的系统与我的websockets在同一个域和相同的端口上!

它实际上是一个Facebook应用程序,例如坐在apps.facebook.com/foo上。 那个画布页面例如是foo.bar.com:8443

然后安全的网络套接字地址也是wss://foo.bar.com:8443!所以我真的不明白为什么我需要首先处理跨域!

非常感谢有关此问题的任何信息!

谢谢

1 个答案:

答案 0 :(得分:0)

我安装了http://code.google.com/p/flashpolicyd/

它在端口843上打开一个服务器,实际上每个请求服务一个poilcy文件。 你有一个接受每个主机和每个端口的策略文件,你需要根据你的需要进行修改。

然后您需要在flex代码中使用xmlsocket://协议将策略文件指向该地址。

    Security.loadPolicyFile("xmlsocket://hostname:843");

就是这样!

相关问题