diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-10-17 16:21:27 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-10-17 16:21:27 +0100 |
commit | 466b2ee661478061e24c7452f781fc0b4cb6a0d6 (patch) | |
tree | 88d5299354fc1f5b2d40ee752588cf43f9d18469 /net/server.lua | |
parent | 6aa6b6e268e14b1d7d46e806ff862af029a89ebe (diff) | |
download | prosody-466b2ee661478061e24c7452f781fc0b4cb6a0d6.tar.gz prosody-466b2ee661478061e24c7452f781fc0b4cb6a0d6.zip |
net.server: Allow changing the sslctx of a connection after it has been established
Diffstat (limited to 'net/server.lua')
-rw-r--r-- | net/server.lua | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/net/server.lua b/net/server.lua index 1260a260..7a740ef1 100644 --- a/net/server.lua +++ b/net/server.lua @@ -531,11 +531,14 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport end
end
- if sslctx then -- ssl?
+ -- Set the sslctx
+ local handshake;
+ function handler.set_sslctx(new_sslctx)
ssl = true
+ sslctx = new_sslctx;
local wrote
local read
- local handshake = coroutine_wrap( function( client ) -- create handshake coroutine
+ handshake = coroutine_wrap( function( client ) -- create handshake coroutine
local err
for i = 1, _maxsslhandshake do
_sendlistlen = ( wrote and removesocket( _sendlist, socket, _sendlistlen ) ) or _sendlistlen
@@ -549,20 +552,20 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport _ = status and status( handler, "ssl-handshake-complete" )
return true
else
- out_put( "server.lua: error during ssl handshake: ", tostring(err) )
- if err == "wantwrite" and not wrote then
- _sendlistlen = _sendlistlen + 1
- _sendlist[ _sendlistlen ] = client
- wrote = true
- elseif err == "wantread" and not read then
- _readlistlen = _readlistlen + 1
- _readlist [ _readlistlen ] = client
- read = true
- else
- break;
- end
- --coroutine_yield( handler, nil, err ) -- handshake not finished
- coroutine_yield( )
+ out_put( "server.lua: error during ssl handshake: ", tostring(err) )
+ if err == "wantwrite" and not wrote then
+ _sendlistlen = _sendlistlen + 1
+ _sendlist[ _sendlistlen ] = client
+ wrote = true
+ elseif err == "wantread" and not read then
+ _readlistlen = _readlistlen + 1
+ _readlist [ _readlistlen ] = client
+ read = true
+ else
+ break;
+ end
+ --coroutine_yield( handler, nil, err ) -- handshake not finished
+ coroutine_yield( )
end
end
disconnect( handler, "ssl handshake failed" )
@@ -570,6 +573,9 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport return false -- handshake failed
end
)
+ end
+ if sslctx then -- ssl?
+ handler.set_sslctx(sslctx);
if startssl then -- ssl now?
--out_put("server.lua: ", "starting ssl handshake")
local err
|