From e8e6bfa098bfe24fd5d6f021f030b64fffa453ff Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 3 Apr 2017 19:49:34 +1000 Subject: Bind SSL_set_SSL_CTX For #84 --- doc/luaossl.pdf | Bin 274644 -> 274840 bytes doc/luaossl.tex | 4 ++++ src/openssl.c | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/doc/luaossl.pdf b/doc/luaossl.pdf index 85c165e..106b4ea 100644 Binary files a/doc/luaossl.pdf and b/doc/luaossl.pdf differ diff --git a/doc/luaossl.tex b/doc/luaossl.tex index bbdf055..e75a678 100644 --- a/doc/luaossl.tex +++ b/doc/luaossl.tex @@ -981,6 +981,10 @@ A table mapping OpenSSL named constants. Includes all constants provided by \mod \subsubsection[\fn{ssl.interpose}]{\fn{ssl.interpose($name$, $function$)}} Add or interpose an ssl class method. Returns the previous method, if any. +\subsubsection[\fn{ssl:setContext}]{\fn{ssl:setContext($context$)}} + +Replaces the \module{openssl.ssl.context} used by $ssl$ with $context$. + \subsubsection[\fn{ssl:setOptions}]{\fn{ssl:setOptions($flags$)}} Adds the option flags of the SSL connection instance. See \fn{openssl.ssl.context:setOptions}. diff --git a/src/openssl.c b/src/openssl.c index dc67d8a..890ca2c 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -8316,6 +8316,18 @@ static int ssl_interpose(lua_State *L) { } /* ssl_interpose() */ +static int ssl_setContext(lua_State *L) { + SSL *ssl = checksimple(L, 1, SSL_CLASS); + SSL_CTX *ctx = checksimple(L, 2, SSL_CTX_CLASS); + + if (!SSL_set_SSL_CTX(ssl, ctx)) + return auxL_error(L, auxL_EOPENSSL, "ssl.setContext"); + + lua_pushboolean(L, 1); + + return 1; +} /* ssl_setContext() */ + static int ssl_setOptions(lua_State *L) { SSL *ssl = checksimple(L, 1, SSL_CLASS); auxL_Integer options = auxL_checkinteger(L, 2); @@ -8676,6 +8688,7 @@ static int ssl__gc(lua_State *L) { static const auxL_Reg ssl_methods[] = { + { "setContext", &ssl_setContext }, { "setOptions", &ssl_setOptions }, { "getOptions", &ssl_getOptions }, { "clearOptions", &ssl_clearOptions }, -- cgit v1.2.3-59-g8ed1b