Fix: check if PSK is available

This commit is contained in:
Bruno Silvestre 2023-03-19 11:43:09 -03:00
parent c297c5204c
commit e01c6e63cd
4 changed files with 17 additions and 1 deletions

View File

@ -54,4 +54,10 @@
//------------------------------------------------------------------------------
#if !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_NO_PSK)
#define LSEC_ENABLE_PSK
#endif
//------------------------------------------------------------------------------
#endif

View File

@ -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");

View File

@ -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},

View File

@ -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"