Help with Cross-Domain file for ActionScript 3 Socket - apache-flex

Here is My ActionScript Code:
var S:Socket=new Socket("127.0.0.1",2222);
Here is My CrossDomain.XML File (Located at http://127.0.0.1/crossdomain.xml)
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" to-ports="2222"/>
</cross-domain-policy>
Here is The Error I Am Getting
Ignoring policy file at xmlsocket://127.0.0.1:2222 due to incorrect syntax.
Having never used one before, I don't understand what's wrong with the syntax of my CrossDomain file.
Please Help.

Socket policy files work a little differently than HTTP policy files; in particular, they aren't served via HTTP, or at port 80.
Instead, Flash Player checks for a policy file server (port 843 by default), or if necessary, on the socket you're opening (for you, port 2222).
A policy file server is a socket which responds to a <policy-file-request/> with a valid policy file. What's happening with your message is likely that it's sending its request and getting something other than a policy file back, hence invalid syntax from port 2222.
There are a lot of resources out there, and a number of questions here on SO. Here's one tutorial from Adobe.

Related

Flex: application trying to access http://localhost/crossdomain.xml on server when no external domain has been specified

I have recently uploaded my flex applicaiton on server, it works fine on my system (localhost) but on the production server it tries to access http://localhost/crossdomain.xml which is not available and end up showing "loading" eternally.
Check your code and see if anywhere you are referencing localhost url.Like,for instance you might be using a localhost url for a httpservice call.
I have a flex client communicating with a zend-framework based server. Client and Server are hosted on different computers (also on the same development computer with different url). What I had to do to make it work is as follows:
I had to edit the file \src\services\_Super_MyHttpService.as in my flex client's source code and update http url from http://localhost/ to http://SERVER_IP/ for variable called _serviceControl. Then compile the flex client.
I also put crossdomain.xml file in the server's root directory with content like:
<?xml verspion="1.0">
<cross-domain-policy>
<allow-access-from domain="CLIENT_IP"/>
</cross-domain-policy>
Note: replace SERVER_IP, CLIENT_IP with the correct IP address where the server and flex clients are hosted respectively.

Security sandbox violation when connecting to Socket from flex

I am using a Socket (not xmlSocket) connection between flex applications and the server pushing messages.
Now, when I connect from the local machine to the server everything is working file and running, connection is succesful and I get data back and forth.
When I upload the application (flex) to the server and run it from there, I get a security sandBox violation message.
Note:
1. I do have a crossdomain file with * wildcard both on port and on domain.
2. I created a Securiy.allowDomain("*") as well.
Another thing.
I also created another listener on that same server, listening to connections for port 843 (default) and this service just waited for a connection send policy file to the client and that's it.
That did not solve the problem as well...
That's next?
What should I do to fix the problem?
Appreciate your help.
Avi
The fix for this issue was a dedicated policy file serving server.
I implemented a socket listening to the dedicated port where flex is looking for policy file, once I got a connection and a request I answered right back with the appropriate policy file.
This solved the problem for all users and is working very well for me.
Thanks
did you try Security.loadPolicyFile? Does your server on port ever actually 843 receive policy file requests (that's a tiny XML sent to request the crossdomain policy file)? Does your actual server ever receive policy file requests? What traffic do you get on your server?
greetz
back2dos
.NET
Add crossdomain.xml to your Web server root directory, for example,
C:\inetpub\wwwroot.
Java
Add crossdomain.xml to \ArcGIS\java\web_output, for example,
C:\Program Files\ArcGIS\java\web_output.
http://resources.esri.com/help/9.3/arcgisserver/apis/flex/help/content/deploy_application.htm

Flex socket crossdomain

I am trying to connect to a socket server from flex.
I read, on adobe's documentation, the client automatically sends a "request-policy-file" xml element to the socket before allowing it to be opened, and should receive a policy file.
The client sends the xml element as expected, My server receives it (on the port I want to use, port 6104) and replies on the same port with:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>
To the best of my knowledge, this should be the most permissive policy available on a socket.
The flash player logs indicate a timeout looking for the socket policy file, although I know my socket returned the response immediately.
What should I do ?
Try using master-only.
Master-only is saying it's using one policy file as a master.
"All" is saying, all domains need a policy file, so it will
keep looking for policy files. Use his and see if you get a timeout.
Cross Domain Policy "master-only"
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>
Reference
http://jodieorourke.com/view.php?id=108&blog=news

calling a web service that has an untrusted certificate using ssl in flex/air

In our flex/air application we are calling a web service over https. The web service is java based and has, at the moment, an untrusted certificate.
When doing a POST to the service with some json, the payload on the server side is pretty garbled. A popup does occur asking whether you want to continue and even when I do and add the untrusted certificate into my keychain (on the mac), the data sent through always comes through mangled.
I installed charles http proxy to see the actual traffic and it seems at times I'm getting a SSLHandshakeException back... I'm guessing this is causing the garbled data as ssl isn't being setup properly.
So, to the question - can air/flex handle untrusted certificates? Is there a workaround that you can do? For example in java with commons httpclient you can work around it at the socket level.
Thanks,
Kieran
I don't know but it might help if you use the secure attribute in your server-side crossdomain.xml like this:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="mydomain.com" secure="false" />
</cross-domain-policy>

Same domain but security error

I am hosting a java service and a flex application on the same server. The flex application accesses the java service. As the flex application loads I get a security error, how can this happen? I thought I do not need a crossdomain.xml when hosting on the same server.
My flex app gets the data via a http service that sends calls to 1.2.3.4:9000/service, the flex application itself lies on 5.6.7.8/test.swf, my crossdomain.xml looks like the following
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="5.6.7.8" to-ports="*" />
</cross-domain-policy>
It is accessible from 1.2.3.4:9000/crossdomain.xml. Note that everything works when I use domain="*" instead of domain="1.2.3.4"
I hope someone can help me
Sebastian
If your Flex app is on the server with ip 5.6.7.8 you need to allow that ip in the crossdomain for the 1.2.3.4 server. This let's the Flash running from 5.6.7.8 know that 1.2.3.4 allows connections from that specific adress.
If you still have the same problem a quick way to find out what's going on is to use a debug proxy (i like Charles). That way you'll see flash' request for the crossdomain.xml and what the response looks like, most likely the request is going somewhere you didn't expect or the server messes it up somehow.
Are you using Sockets?
In that case you need to serve Policy Files either with your existing Java Server or a standalone one.
http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html
Does 1.2.3.4 represent an IP address?
If so I believe you have to use a domain name here not an ip address, otherwise you could have several domains on the same server and bypass the same domain checks.

Resources