Comparison

net/server_select.lua @ 4888:c3e17766aead

net.server_select: Return error when SSL handshake fails immediately (thanks Zash)
author Matthew Wild <mwild1@gmail.com>
date Fri, 18 May 2012 00:27:06 +0100
parent 4808:07d0a3a75c8a
child 4903:c576d2175fa4
comparison
equal deleted inserted replaced
4887:4dd61fe04db4 4888:c3e17766aead
548 end 548 end
549 end 549 end
550 out_put( "server.lua: ssl handshake error: ", tostring(err or "handshake too long") ) 550 out_put( "server.lua: ssl handshake error: ", tostring(err or "handshake too long") )
551 disconnect( handler, "ssl handshake failed" ) 551 disconnect( handler, "ssl handshake failed" )
552 _ = handler and handler:close( true ) -- forced disconnect 552 _ = handler and handler:close( true ) -- forced disconnect
553 return false -- handshake failed 553 return false, err -- handshake failed
554 end 554 end
555 ) 555 )
556 end 556 end
557 if luasec then 557 if luasec then
558 handler.starttls = function( self, _sslctx) 558 handler.starttls = function( self, _sslctx)
592 -- Secure now (if handshake fails connection will close) 592 -- Secure now (if handshake fails connection will close)
593 ssl = true 593 ssl = true
594 594
595 handler.readbuffer = handshake 595 handler.readbuffer = handshake
596 handler.sendbuffer = handshake 596 handler.sendbuffer = handshake
597 handshake( socket ) -- do handshake 597 return handshake( socket ) -- do handshake
598 end 598 end
599 end 599 end
600 600
601 handler.readbuffer = _readbuffer 601 handler.readbuffer = _readbuffer
602 handler.sendbuffer = _sendbuffer 602 handler.sendbuffer = _sendbuffer
608 _readlistlen = addsocket(_readlist, socket, _readlistlen) 608 _readlistlen = addsocket(_readlist, socket, _readlistlen)
609 609
610 if sslctx and luasec then 610 if sslctx and luasec then
611 out_put "server.lua: auto-starting ssl negotiation..." 611 out_put "server.lua: auto-starting ssl negotiation..."
612 handler.autostart_ssl = true; 612 handler.autostart_ssl = true;
613 handler:starttls(sslctx); 613 local ok, err = handler:starttls(sslctx);
614 if ok == false then
615 return nil, nil, err
616 end
614 end 617 end
615 618
616 return handler, socket 619 return handler, socket
617 end 620 end
618 621