Mercurial > prosody-hg
diff net/tls_luasec.lua @ 13115:749376d75b40
net.certmanager: Move LuaSec feature detection to net.tls_luasec
Further isolates LuaSec from Prosody core, with the ultimate goal of
allowing LuaSec to be replaced more easily.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 27 May 2023 15:39:26 +0200 |
| parents | ee93df086926 |
| children | 58e793288d9c |
line wrap: on
line diff
--- a/net/tls_luasec.lua Fri May 26 21:18:27 2023 +0200 +++ b/net/tls_luasec.lua Sat May 27 15:39:26 2023 +0200 @@ -84,6 +84,30 @@ }, context_mt), nil end +-- Feature detection / guessing +local function test_option(option) + return not not ssl_newcontext({mode="server",protocol="sslv23",options={ option }}); +end +local luasec_major, luasec_minor = ssl._VERSION:match("^(%d+)%.(%d+)"); +local luasec_version = tonumber(luasec_major) * 100 + tonumber(luasec_minor); +local luasec_has = ssl.config or { + algorithms = { + ec = luasec_version >= 5; + }; + capabilities = { + curves_list = luasec_version >= 7; + }; + options = { + cipher_server_preference = test_option("cipher_server_preference"); + no_ticket = test_option("no_ticket"); + no_compression = test_option("no_compression"); + single_dh_use = test_option("single_dh_use"); + single_ecdh_use = test_option("single_ecdh_use"); + no_renegotiation = test_option("no_renegotiation"); + }; +}; + return { + features = luasec_has; new_context = new_context, };
