diff options
author | daurnimator <quae@daurnimator.com> | 2018-07-08 20:58:02 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-07-08 20:58:02 +1000 |
commit | 6b0ddff8b33d533c077a16007d17899203743501 (patch) | |
tree | cb03776f8e5e4a3c9dba20b04925c30b9617e577 | |
parent | 480abc01f542d82bcd4a2d6767fa51d704ef7d7a (diff) | |
download | luaossl-6b0ddff8b33d533c077a16007d17899203743501.tar.gz luaossl-6b0ddff8b33d533c077a16007d17899203743501.tar.bz2 luaossl-6b0ddff8b33d533c077a16007d17899203743501.zip |
src/openssl.c: Move ticket keys length discovery to own function :getTicketKeysLength()
-rw-r--r-- | src/openssl.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/openssl.c b/src/openssl.c index 0cc0f14..1aa0206 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -8946,20 +8946,23 @@ static int sx_getTLSextStatusType(lua_State *L) { #if HAVE_SSL_CTX_SET_TLSEXT_TICKET_KEYS -static int sx_setTicketKeys(lua_State *L) { +static int sx_getTicketKeysLength(lua_State *L) { SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); - size_t keylen; - const char *keys = luaL_optlstring(L, 2, NULL, &keylen); - int res = SSL_CTX_set_tlsext_ticket_keys(ctx, (void*)keys, keylen); + int res = SSL_CTX_set_tlsext_ticket_keys(ctx, NULL, 0); - if (keys == NULL) { - /* returns expected 'keys' length */ - lua_pushinteger(L, res); - return 1; - } + lua_pushinteger(L, res); + + return 1; +} /* sx_getTicketKeysLength() */ + + +static int sx_setTicketKeys(lua_State *L) { + SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); + size_t keylen; + const char *keys = luaL_checklstring(L, 2, &keylen); - if (res == 0) + if (!SSL_CTX_set_tlsext_ticket_keys(ctx, (void*)keys, keylen)) return auxL_error(L, auxL_EOPENSSL, "ssl.context:setTicketKeys"); lua_pushboolean(L, 1); @@ -9036,6 +9039,7 @@ static const auxL_Reg sx_methods[] = { { "getTLSextStatusType", &sx_getTLSextStatusType }, #endif #if HAVE_SSL_CTX_SET_TLSEXT_TICKET_KEYS + { "getTicketKeysLength", &sx_getTicketKeysLength }, { "setTicketKeys", &sx_setTicketKeys }, #endif #if HAVE_SSL_CTX_GET_TLSEXT_TICKET_KEYS |