mirror of
https://github.com/brunoos/luasec.git
synced 2024-12-26 20:48:22 +01:00
Do not wrap the PSK callbacks
This commit is contained in:
parent
4f28db9f53
commit
6708ccc381
20
src/ssl.lua
20
src/ssl.lua
@ -203,25 +203,17 @@ local function newcontext(cfg)
|
||||
|
||||
-- PSK
|
||||
if cfg.psk then
|
||||
if type(cfg.psk) == "function" then
|
||||
local pskcb = cfg.psk
|
||||
if type(cfg.psk) ~= "function" then
|
||||
return nil, "invalid PSK callback parameter"
|
||||
end
|
||||
|
||||
if cfg.mode == "client" then
|
||||
succ, msg = context.setclientpskcb(ctx, function(hint, max_psk_len)
|
||||
local identity, psk = pskcb(hint, max_psk_len)
|
||||
return identity, psk
|
||||
end)
|
||||
succ, msg = context.setclientpskcb(ctx, cfg.psk)
|
||||
if not succ then return nil, msg end
|
||||
else
|
||||
succ, msg = context.setserverpskcb(ctx, function(identity, max_psk_len)
|
||||
local psk = pskcb(identity, max_psk_len)
|
||||
return psk
|
||||
end)
|
||||
elseif cfg.mode == "server" then
|
||||
succ, msg = context.setserverpskcb(ctx, cfg.psk)
|
||||
if not succ then return nil, msg end
|
||||
end
|
||||
else
|
||||
return nil, "invalid PSK Callback parameter"
|
||||
end
|
||||
end
|
||||
|
||||
if config.capabilities.dane and cfg.dane then
|
||||
|
Loading…
Reference in New Issue
Block a user