0

我正在尝试将 Flex 应用程序与 Google Checkout 集成,并且在我的本地计算机上运行良好的代码在我的网站上进行测试时会引发安全错误。

这是错误:

Warning: Failed to load policy file from https://sandbox.google.com/crossdomain.xml

*** Security Sandbox Violation ***
Connection to https://sandbox.google.com/checkout/api/checkout/v2/request/Merchant/12345 halted - not permitted from http://www.mysite.com/demo/cartTest/main.swf
ERROR (flash.events::SecurityErrorEvent)#0
  bubbles = false
  cancelable = false
  currentTarget = (flash.net::URLLoader)#1
    bytesLoaded = 0
    bytesTotal = 0
    data = (null)
    dataFormat = "text"
  eventPhase = 2
  target = (flash.net::URLLoader)#1
  text = "Error #2170: Security sandbox violation: http://www.mysite.com/demo/cartTest/main.swf cannot send HTTP headers to https://sandbox.google.com/checkout/api/checkout/v2/request/Merchant/12345."
  type = "securityError"
Error: Request for resource at https://sandbox.google.com/checkout/api/checkout/v2/request/Merchant/12345 by requestor from http://www.mysite.com/demo/cartTest/main.swf is denied due to lack of policy file permissions.

就像我说的,它在本地运行良好。我怎样才能绕过这个安全错误?

4

3 回答 3

1

为了解决这个问题,我在 Flex 中组装了一个 html 表单,然后将其传递给页面上的 js,将其附加到页面上的一个空表单,然后提交该表单。我将表单隐藏,因此所有 UI 输入和操作都发生在 swf 中。我不喜欢它,但我会忍受它。

于 2010-05-13T14:18:17.250 回答
0

crossdomain.xml 文件是一种安全约束,通常旨在防止恶意行为。当您在本地运行 SWF 时,权限会有所不同。

如果您向其他域发出请求,则该其他域必须托管 crossdomain.xml 文件。如果他们不这样做,它将无法正常工作。例如,亚马逊托管了一个 crossdomain.xml 文件

这个先前的 StackOverflow 线程为您提供了一些选项。

另请参阅 Curtis Morley关于 crossdomain.xml 文件的帖子。

于 2010-03-30T19:44:43.383 回答
0

您正在从中加载 swfhttp:并尝试访问https:URL。默认情况下,这将被阻止(错误 #2170)。

要使其正常工作,目标域(您尝试从 Flash 访问的域)应该有一个/crossdomain.xml允许不安全访问的域 (secure="false")。如果crossdomain.xml您可以在目标URL 的根目录(即https://sandbox.google.com/crossdomain.xml

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

有关安全标志的更多信息:http: //www.adobe.com/devnet/..../fplayer9_security.html#_Secure_Domain_Lists

于 2015-01-19T10:58:42.890 回答