rakuten / as3crypto

Automatically exported from code.google.com/p/as3crypto
0 stars 1 forks source link

TLSSocket doesn't send handshake #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create TLSSocket
2. connect socket

What is the expected output? What do you see instead?
It is expected to see the handshake, but I see nothing.

What version of the product are you using? On what operating system?
HEAD revision of svn, Win XP, Firefox 3.0.2 with Flash Player 9.0 r124

Please provide any additional information below.

I realized that the problem occurs because the handshake is sent before
Event.CONNECT is raised on the inner socket. I delayed engine.start() after
the connection was made, and my problem was solved.

Extrangely, the problem doesn't happen using the Stand Alone Player
(version 9,0,124,0)

Original issue reported on code.google.com by ignacioa...@gmail.com on 26 Sep 2008 at 7:20

Attachments:

GoogleCodeExporter commented 9 years ago
ignacioalles's fix worked wonders for me when my client would not handshake 
with a 
server.

Thx ignacioalles!

Original comment by ockky...@gmail.com on 15 Jan 2009 at 7:34

GoogleCodeExporter commented 9 years ago
You're welcome. Are you developing a web application? Or a desktop one?

I think it would be nice to have it applied to the project. 

Original comment by ignacioa...@gmail.com on 15 Jan 2009 at 7:50

GoogleCodeExporter commented 9 years ago
Incorporated most of this into the current commit.

Original comment by sh0rtw...@gmail.com on 4 Jun 2009 at 11:42

GoogleCodeExporter commented 9 years ago
Hello,
We are trying to connect with a JAVA socket server.
Without the encryption it works fine.
Encryption enabled, connection works fine ( note: debug player )
But when published for flash player 10.2 in a browser ( Published with Flex or 
CS5 ) as (sandboxtype:remote), doesn't work anymore...

In short:
At first without encryption, connection works fine as sandboxtype: remote.
So, policy file is exchanged etc. and connection is made.
After as3crypto wrapper it connects fine in debug player ( 
sandboxtype:localThrusted )
Of course here is no policy file exchanged...
Chears!

Original comment by i.cazem...@gmail.com on 8 Mar 2011 at 2:39

GoogleCodeExporter commented 9 years ago
Hello everybody,

We debugged the as3crypto side, en determined that there is something wrong 
with the handshaking routines ( sandbox:remote ). The weird thing is, that when 
you try to connect a few times, the connection is estabished... Every time you 
must connect a few times...
But in de sandbox:thrusted local, one connect action is needed to connect...

So, at the moment looking at JAVA side...

Anybody?

Cheers ( not Chears ).

Ivo

Original comment by i.cazem...@gmail.com on 13 Mar 2011 at 1:34

GoogleCodeExporter commented 9 years ago
Guys,

Please read:"http://forums.adobe.com/thread/497758?tstart=0"
Mister bjohnston@bsecure.com allready solved my problem!!! Thank you buddy!

Why are these changes improvements not commited???
[code]
        public function connect(host:String, port:int, config:TLSConfig = null):void {
            init(new Socket, config, host);
            _socket.connect(host, port);
            // make sure socket connects before having the engine start to use it
            //_engine.start();
        }

        public function startTLS(socket:Socket, host:String, config:TLSConfig = null):void {
            if (!socket.connected) {
                throw new Error("Cannot STARTTLS on a socket that isn't connected.");
            }
            init(socket, config, host);
            _engine.start();
        }

        private function init(socket:Socket, config:TLSConfig, host:String):void {
            _iStream = new ByteArray;
            _oStream = new ByteArray;
            _iStream_cursor = 0;
            objectEncoding = ObjectEncoding.DEFAULT;
            endian = Endian.BIG_ENDIAN;
            _socket = socket;
            //_socket.addEventListener(Event.CONNECT, dispatchEvent);
      // make sure socket connects before having the engine start to use it
      _socket.addEventListener(Event.CONNECT, onSocketConnected);
            _socket.addEventListener(IOErrorEvent.IO_ERROR, dispatchEvent);
            _socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, dispatchEvent);
            _socket.addEventListener(Event.CLOSE, dispatchEvent);

            if (config == null) {
                config = new TLSConfig(TLSEngine.CLIENT);
            }

            _engine = new TLSEngine(config, _socket, _socket, host);

            _engine.addEventListener(TLSEvent.DATA, onTLSData);
            _engine.addEventListener(TLSEvent.READY, onTLSReady);
            _engine.addEventListener(Event.CLOSE, onTLSClose);
            _engine.addEventListener(ProgressEvent.SOCKET_DATA, function(e:*):void { _socket.flush(); });
            _socket.addEventListener(ProgressEvent.SOCKET_DATA, _engine.dataAvailable);

            _ready = false;
        }

    // make sure socket connects before having the engine start to use it
        private function onSocketConnected(evt:Event):void
        {
          _engine.start();
          this.dispatchEvent(evt);
        }

        public function flush():void {
            commitWrite();
            _socket.flush();
        }

[/code]

Original comment by i.cazem...@gmail.com on 16 Mar 2011 at 8:34

GoogleCodeExporter commented 9 years ago
Thank you VERY much. I've spent ages checking my code, checking the many 
examples (with plain sockets), checking traffic, and wondering WHY it wasn't 
working (note there are examples for standard sockets out there that suffer the 
same problem namely using the socked before it's ready).
I only found the root problem when using openssl s_server, and I could see 
there was a problem with the handshake.
This change is really important; without it TLSSocket is pretty broken. We 
should let Mr. Hurlant (who I am also very grateful to) know.
Thanks again (and bjonhston),
Nick

Original comment by nick.p.d...@gmail.com on 27 Oct 2011 at 5:04

GoogleCodeExporter commented 9 years ago
Yes!

As I mentioned : "Why are these changes improvements not commited???"

At the moment, we left AS3Crypto development, and use red5 already...

Ivo

Original comment by i.cazem...@gmail.com on 28 Oct 2011 at 10:42