Skip to main content
Participant
June 3, 2011
Question

Binary Socket Security

  • June 3, 2011
  • 1 reply
  • 602 views

Hello,

The documentation is a bit sparse on what to do with binary sockets and the security model.  Particularily what it means to 'return a cross domain policy file' ( See Section 1.4.3 and 1.5.6 of Cross Domain Policy File Documentation http://learn.adobe.com/wiki/download/attachments/64389123/CrossDomain_PolicyFile_Specification.pdf?version=1 )

This is what my socket server code looks like in PHP:

(PHP)

if (strcmp( substr($input,0,22), "<policy-file-request/>") == 0 ){              

     socket_write($socket,"<?xml version=\"1.0\"?>\n<!DOCTYPE cross-domain-policy SYSTEM\n\"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd\">\n<cross-domain-policy>\n<allow-access-from domain=\"*\" to-ports=\"4041\"/>\n</cross-domain-policy>\n\n");

}

When I run my AS3 code

var socket:Socket = new Socket();      

socket.endian = Endian.BIG_ENDIAN;

socket.addEventListener(Event.CLOSE, close);

socket.addEventListener(Event.CONNECT, connected);

socket.addEventListener(IOErrorEvent.IO_ERROR, io_error );

socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, security_error );

socket.addEventListener(ProgressEvent.SOCKET_DATA, socket_data);   

socket.addEventListener(Event.DEACTIVATE, close);

socket.timeout = 3000;

socket.connect(host,4041);      

The client does ask for the security file,  but after the server writes the security file to the socket the client socket shuts down and returns a security error.

What am I doing wrong?  Should the server be outputting a URL where the crossdomain.xml is located instead?  I don't understand what nuance I am missing.


Could someone please explain what I am missing?

Thanks

This topic has been closed for replies.

1 reply

TheSueseAuthor
Participant
June 3, 2011

My problem was that I was sending binary data through the socket previous to sending the policy file.  I just sent the policy file immediately upon connect and everything worked out fine.   I had to add a chr(0) to the end of the policy file as well.

Thanks for your time.