3 Replies Latest reply on Aug 18, 2009 6:14 AM by LadislavS

    Problem with socket security

    LadislavS

      Hi,

       

      I'm trying to make socket connection from within air application, but no way. I'm browsing google for almost 2 days, follow all possible solutions, but avidently I dont understund somthing cause I'm not able to do anything.

      Every time sandbox security violation.....  I need make some simple socket data exchange between my air, and OS. I do not have any web server and no any other kind of network ability. I write down stupid socket server, which is waiting for policy request, and for my other requests (it function 100%, tested with Telnet, so no way to have problem on my socket server side).

       

      The strange thing is that my application do not produce any request for socket policy file, neither at 843 port (for default), neither at my custom location with namual

      Security.loadPolicyFile("xmlsocket://ip:port"); call

       

      This is my primitive code:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
          layout="vertical">
          <mx:Script>
              <![CDATA[
                  private var s:XMLSocket = null;
                     
                  private function test():void{
                      Security.loadPolicyFile("xmlsocket://127.0.0.1:25013");
                      if(!s){
                          s = new XMLSocket();
                          s.addEventListener(DataEvent.DATA, onData);
                          s.addEventListener(Event.ACTIVATE, onActivate);
                          s.addEventListener(Event.CONNECT, onConnect);
                          s.addEventListener(Event.DEACTIVATE, onDeactivate);
                          s.addEventListener(IOErrorEvent.IO_ERROR, onError);
                          s.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurity);
                      }
                      s.connect("127.0.0.1", 25013);
                  }
                 
                  private function onActivate(e:Event):void{
                      debug.text += "Activated\r";
                  }
                 
                  private function onConnect(e:Event):void{
                      debug.text += "Connected\r";
                      var o:XML = <request cmd="10"/>;
                      s.send(o);
                  }
                 
                  private function onDeactivate(e:Event):void{
                      debug.text += "Deactivated\r";
                  }
                 
                  private function onError(e:IOErrorEvent):void{
                      debug.text += e.text + "\r";
                  }
                 
                  private function onSecurity(e:SecurityErrorEvent):void{
                      debug.text += e.text + "\r";
                  }
                 
                  private function onData(e:DataEvent):void{
                      debug.text += e.data;
                      s.close();
                  }
              ]]>
          </mx:Script>
          <mx:Button label="Test" click="test()"/>
          <mx:TextArea id="debug" width="100%" height="100%"/>
      </mx:WindowedApplication>

       

      Any help will be apresciated.

       

       

      Ladislav.

        • 1. Re: Problem with socket security
          LadislavS Level 1

          I found!

           

          Its not security problem!!!!

           

          If server response is not '\0'   terminated it give security error!

           

          Error #2048: Security sandbox violation: app:/TestSocket.swf cannot load data from 10.17.61.108:843

           

          even if its not security problem!!!!

           

           

          Damn!!!! 2 days lost looking for security problems even if it was problem with not correct error message!.

           

          Good, anyway at least I can move my self a bit.

           

          Ladislav

          • 2. Re: Problem with socket security
            Staney G Level 1

            So, how did you walk around the problem?  Did you have a control on how server responds?

             

            My test case failed similarly.  However, the target server is a public web service.

             

            Will appreciate your answers!

            • 3. Re: Problem with socket security
              LadislavS Level 1

              Hi,

              It pass some time but if i remember well, my problem was that i did

              not terminate stream output form my server vs air application, and it

              returns this security error.

              When I send  '\0' at the end of my message it work correctly. Yes the

              server was my own written socket server (c++ using boost libraries).

               

              Laco.

               

              Sorry late response I'm on hollydays

               

               

               

              Staney G ha scritto:

              So, how did you walk around the problem?  Did you have a control on how server responds?

               

              My test case failed similarly.  However, the target server is a public web service.

               

              Will appreciate your answers!

              >