diff options
| -rw-r--r-- | src/openssl.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index 8d513e6..e6ae71d 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
| @@ -7532,6 +7532,38 @@ static int sx_getStore(lua_State *L) { | |||
| 7532 | } /* sx_getStore() */ | 7532 | } /* sx_getStore() */ |
| 7533 | 7533 | ||
| 7534 | 7534 | ||
| 7535 | static int sx_setParam(lua_State *L) { | ||
| 7536 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); | ||
| 7537 | X509_VERIFY_PARAM *xp = checksimple(L, 2, X509_VERIFY_PARAM_CLASS); | ||
| 7538 | |||
| 7539 | if (!SSL_CTX_set1_param(ctx, xp)) | ||
| 7540 | return auxL_error(L, auxL_EOPENSSL, "ssl.context:setParam"); | ||
| 7541 | |||
| 7542 | lua_pushboolean(L, 1); | ||
| 7543 | |||
| 7544 | return 1; | ||
| 7545 | } /* sx_setParam() */ | ||
| 7546 | |||
| 7547 | |||
| 7548 | static int sx_getParam(lua_State *L) { | ||
| 7549 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); | ||
| 7550 | X509_VERIFY_PARAM **ud, *from; | ||
| 7551 | |||
| 7552 | /* X509_VERIFY_PARAM is not refcounted; create a new object and copy into it. */ | ||
| 7553 | ud = prepsimple(L, X509_VERIFY_PARAM_CLASS); | ||
| 7554 | if (!(*ud = X509_VERIFY_PARAM_new())) | ||
| 7555 | return auxL_error(L, auxL_EOPENSSL, "ssl.context:getParam"); | ||
| 7556 | |||
| 7557 | from = SSL_CTX_get0_param(ctx); | ||
| 7558 | |||
| 7559 | if (!(X509_VERIFY_PARAM_set1(*ud, from))) | ||
| 7560 | /* Note: openssl doesn't set an error as it should for some cases */ | ||
| 7561 | return auxL_error(L, auxL_EOPENSSL, "ssl.context:getParam"); | ||
| 7562 | |||
| 7563 | return 1; | ||
| 7564 | } /* sx_getParam() */ | ||
| 7565 | |||
| 7566 | |||
| 7535 | static int sx_setVerify(lua_State *L) { | 7567 | static int sx_setVerify(lua_State *L) { |
| 7536 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); | 7568 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); |
| 7537 | int mode = luaL_optint(L, 2, -1); | 7569 | int mode = luaL_optint(L, 2, -1); |
| @@ -7799,6 +7831,8 @@ static const auxL_Reg sx_methods[] = { | |||
| 7799 | { "clearOptions", &sx_clearOptions }, | 7831 | { "clearOptions", &sx_clearOptions }, |
| 7800 | { "setStore", &sx_setStore }, | 7832 | { "setStore", &sx_setStore }, |
| 7801 | { "getStore", &sx_getStore }, | 7833 | { "getStore", &sx_getStore }, |
| 7834 | { "setParam", &sx_setParam }, | ||
| 7835 | { "getParam", &sx_getParam }, | ||
| 7802 | { "setVerify", &sx_setVerify }, | 7836 | { "setVerify", &sx_setVerify }, |
| 7803 | { "getVerify", &sx_getVerify }, | 7837 | { "getVerify", &sx_getVerify }, |
| 7804 | { "setCertificate", &sx_setCertificate }, | 7838 | { "setCertificate", &sx_setCertificate }, |
