Flash Socket Policy - Policy is served, but client

2019-09-16 15:34发布

问题:

I have a service set up on port 2400. When I run the Flash client from Flash itself, it runs fine because it bypasses security policy.

When I try to connect by running the SWF on my desktop, or from the browser, I see this exchange:

00000000  3c 70 6f 6c 69 63 79 2d  66 69 6c 65 2d 72 65 71 <policy- file-req
00000010  75 65 73 74 2f 3e 00                             uest/>.

00000000  3c 3f 78 6d 6c 20 76 65  72 73 69 6f 6e 3d 22 31 <?xml ve rsion="1
00000010  2e 30 22 3f 3e 3c 21 44  4f 43 54 59 50 45 20 63 .0"?><!D OCTYPE c
00000020  72 6f 73 73 2d 64 6f 6d  61 69 6e 2d 70 6f 6c 69 ross-dom ain-poli
00000030  63 79 20 53 59 53 54 45  4d 20 22 68 74 74 70 3a cy SYSTE M "http:
00000040  2f 2f 77 77 77 2e 61 64  6f 62 65 2e 63 6f 6d 2f //www.ad obe.com/
00000050  78 6d 6c 2f 64 74 64 73  2f 63 72 6f 73 73 2d 64 xml/dtds /cross-d
00000060  6f 6d 61 69 6e 2d 70 6f  6c 69 63 79 2e 64 74 64 omain-po licy.dtd
00000070  22 3e 20 3c 63 72 6f 73  73 2d 64 6f 6d 61 69 6e "> <cros s-domain
00000080  2d 70 6f 6c 69 63 79 3e  20 3c 73 69 74 65 2d 63 -policy>  <site-c
00000090  6f 6e 74 72 6f 6c 20 70  65 72 6d 69 74 74 65 64 ontrol p ermitted
000000A0  2d 63 72 6f 73 73 2d 64  6f 6d 61 69 6e 2d 70 6f -cross-d omain-po
000000B0  6c 69 63 69 65 73 3d 22  6d 61 73 74 65 72 2d 6f licies=" master-o
000000C0  6e 6c 79 22 2f 3e 20 3c  61 6c 6c 6f 77 2d 61 63 nly"/> < allow-ac
000000D0  63 65 73 73 2d 66 72 6f  6d 20 64 6f 6d 61 69 6e cess-fro m domain
000000E0  3d 22 2a 22 20 74 6f 2d  70 6f 72 74 73 3d 22 2a ="*" to- ports="*
000000F0  22 20 2f 3e 3c 2f 63 72  6f 73 73 2d 64 6f 6d 61 " /></cr oss-doma
00000100  69 6e 2d 70 6f 6c 69 63  79 3e 00                in-polic y>.

So you can see that I'm correctly including the null terminator in the response.

After the exchange of the policy request and policy file being served, the following happens:

  • Client sends SYN to server port 2400
  • Server responds SYN, ACK
  • Client sends ACK
  • Client sends FIN, ACK
  • Server responds ACK
  • Client sends RST, ACK

I'm assuming this is the client connecting (steps 1-3) then aborting (steps 4-6). Flash provides this error:

Error: Error #2048: Security sandbox violation: file:///C|/Projects/rbrnascar/trunk/Development/Websites/flash/SocialMap.swf cannot load data from robpaveza.net:2400.
    at com.redbull.model::SocialMapModel/onSecurityError()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::Socket/onTimeout()
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()

I've looked at the following pages, which seem to express similar troubles but no resolutions

  • Trouble getting Flash socket policy file to work
  • Adobe Socket Policy File Server Problems
  • flash socket policy
  • Flash doesn't connect to socket even though policy allows it

Has anyone figured this out?

回答1:

Make sure that the client's timeout is set in milliseconds, not seconds.



回答2:

I have. Send the null character \0 after the end of the policy file.

Here's how I would go about doing it (writing to a StreamWriter in C#)

 mwriter.WriteLine(XMLString+"\0");