diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 22 | ||||
-rw-r--r-- | src/openssl.ssl.lua | 20 |
2 files changed, 40 insertions, 2 deletions
diff --git a/src/openssl.c b/src/openssl.c index 652e38a..8217deb 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
@@ -294,6 +294,10 @@ | |||
294 | #define HAVE_SSL_SET_ALPN_PROTOS HAVE_SSL_CTX_SET_ALPN_PROTOS | 294 | #define HAVE_SSL_SET_ALPN_PROTOS HAVE_SSL_CTX_SET_ALPN_PROTOS |
295 | #endif | 295 | #endif |
296 | 296 | ||
297 | #ifndef HAVE_SSL_SET_CURVES_LIST | ||
298 | #define HAVE_SSL_SET_CURVES_LIST (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,5,1)) | ||
299 | #endif | ||
300 | |||
297 | #ifndef HAVE_SSL_SET1_PARAM | 301 | #ifndef HAVE_SSL_SET1_PARAM |
298 | #define HAVE_SSL_SET1_PARAM OPENSSL_PREREQ(1,0,2) | 302 | #define HAVE_SSL_SET1_PARAM OPENSSL_PREREQ(1,0,2) |
299 | #endif | 303 | #endif |
@@ -8214,6 +8218,21 @@ static int ssl_getCipherInfo(lua_State *L) { | |||
8214 | } /* ssl_getCipherInfo() */ | 8218 | } /* ssl_getCipherInfo() */ |
8215 | 8219 | ||
8216 | 8220 | ||
8221 | #if HAVE_SSL_SET_CURVES_LIST | ||
8222 | static int ssl_setCurvesList(lua_State *L) { | ||
8223 | SSL *ssl = checksimple(L, 1, SSL_CLASS); | ||
8224 | const char *curves = luaL_checkstring(L, 2); | ||
8225 | |||
8226 | if (!SSL_set1_curves_list(ssl, curves)) | ||
8227 | return auxL_error(L, auxL_EOPENSSL, "ssl:setCurvesList"); | ||
8228 | |||
8229 | lua_pushboolean(L, 1); | ||
8230 | |||
8231 | return 1; | ||
8232 | } /* ssl_setCurvesList() */ | ||
8233 | #endif | ||
8234 | |||
8235 | |||
8217 | static int ssl_getHostName(lua_State *L) { | 8236 | static int ssl_getHostName(lua_State *L) { |
8218 | SSL *ssl = checksimple(L, 1, SSL_CLASS); | 8237 | SSL *ssl = checksimple(L, 1, SSL_CLASS); |
8219 | const char *host; | 8238 | const char *host; |
@@ -8357,6 +8376,9 @@ static const auxL_Reg ssl_methods[] = { | |||
8357 | { "getPeerCertificate", &ssl_getPeerCertificate }, | 8376 | { "getPeerCertificate", &ssl_getPeerCertificate }, |
8358 | { "getPeerChain", &ssl_getPeerChain }, | 8377 | { "getPeerChain", &ssl_getPeerChain }, |
8359 | { "getCipherInfo", &ssl_getCipherInfo }, | 8378 | { "getCipherInfo", &ssl_getCipherInfo }, |
8379 | #if HAVE_SSL_SET_CURVES_LIST | ||
8380 | { "setCurvesList", &ssl_setCurvesList }, | ||
8381 | #endif | ||
8360 | { "getHostName", &ssl_getHostName }, | 8382 | { "getHostName", &ssl_getHostName }, |
8361 | { "setHostName", &ssl_setHostName }, | 8383 | { "setHostName", &ssl_setHostName }, |
8362 | { "getVersion", &ssl_getVersion }, | 8384 | { "getVersion", &ssl_getVersion }, |
diff --git a/src/openssl.ssl.lua b/src/openssl.ssl.lua index 3c348f6..bf90f29 100644 --- a/src/openssl.ssl.lua +++ b/src/openssl.ssl.lua | |||
@@ -1,3 +1,19 @@ | |||
1 | local ctx = require"_openssl.ssl" | 1 | local ssl = require"_openssl.ssl" |
2 | 2 | ||
3 | return ctx | 3 | local pack = table.pack or function(...) return { n = select("#", ...); ... } end |
4 | |||
5 | -- Allow passing a vararg of curves, or an array | ||
6 | local setCurvesList = ssl.interpose("setCurvesList", nil) | ||
7 | if setCurvesList then | ||
8 | ssl.interpose("setCurvesList", function (self, curves, ...) | ||
9 | if (...) then | ||
10 | local curves_t = pack(curves, ...) | ||
11 | curves = table.concat(curves_t, ":", 1, curves_t.n) | ||
12 | elseif type(curves) == "table" then | ||
13 | curves = table.concat(curves, ":") | ||
14 | end | ||
15 | return setCurvesList(self, curves) | ||
16 | end) | ||
17 | end | ||
18 | |||
19 | return ssl | ||