mirror of
https://github.com/brunoos/luasec.git
synced 2024-12-26 04:48:20 +01:00
Fix: check if PSK is available
This commit is contained in:
parent
c297c5204c
commit
e01c6e63cd
@ -54,4 +54,10 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_NO_PSK)
|
||||
#define LSEC_ENABLE_PSK
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
|
@ -74,6 +74,12 @@ LSEC_API int luaopen_ssl_config(lua_State *L)
|
||||
lua_pushboolean(L, 1);
|
||||
lua_rawset(L, -3);
|
||||
|
||||
#ifdef LSEC_ENABLE_PSK
|
||||
lua_pushstring(L, "psk");
|
||||
lua_pushboolean(L, 1);
|
||||
lua_rawset(L, -3);
|
||||
#endif
|
||||
|
||||
#ifdef LSEC_ENABLE_DANE
|
||||
// DANE
|
||||
lua_pushstring(L, "dane");
|
||||
|
@ -707,6 +707,7 @@ static int set_alpn_cb(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(LSEC_ENABLE_PSK)
|
||||
/**
|
||||
* Callback to select the PSK.
|
||||
*/
|
||||
@ -841,6 +842,7 @@ static int set_client_psk_cb(lua_State *L) {
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LSEC_ENABLE_DANE)
|
||||
/*
|
||||
@ -893,9 +895,11 @@ static luaL_Reg funcs[] = {
|
||||
{"setdhparam", set_dhparam},
|
||||
{"setverify", set_verify},
|
||||
{"setoptions", set_options},
|
||||
#if defined(LSEC_ENABLE_PSK)
|
||||
{"setpskhint", set_psk_identity_hint},
|
||||
{"setserverpskcb", set_server_psk_cb},
|
||||
{"setclientpskcb", set_client_psk_cb},
|
||||
#endif
|
||||
{"setmode", set_mode},
|
||||
#if !defined(OPENSSL_NO_EC)
|
||||
{"setcurve", set_curve},
|
||||
|
@ -202,7 +202,7 @@ local function newcontext(cfg)
|
||||
end
|
||||
|
||||
-- PSK
|
||||
if cfg.psk then
|
||||
if config.capabilities.psk and cfg.psk then
|
||||
if cfg.mode == "client" then
|
||||
if type(cfg.psk) ~= "function" then
|
||||
return nil, "invalid PSK configuration"
|
||||
|
Loading…
Reference in New Issue
Block a user