diff options
| author | William Ahern <william@25thandclement.com> | 2016-11-23 18:11:58 -0800 |
|---|---|---|
| committer | William Ahern <william@25thandclement.com> | 2016-11-23 18:11:58 -0800 |
| commit | c0febd5bcc823b6df11d39af65297fe24c49163a (patch) | |
| tree | e6329fa1b5f3e72809b1faf61834079692483e4a | |
| parent | 7dbd5609c0866a101b3e0715e32ab704d91e416f (diff) | |
| parent | a45ea1e4ffd195c45cde3f79df576460272b66fa (diff) | |
| download | luaossl-c0febd5bcc823b6df11d39af65297fe24c49163a.tar.gz luaossl-c0febd5bcc823b6df11d39af65297fe24c49163a.tar.bz2 luaossl-c0febd5bcc823b6df11d39af65297fe24c49163a.zip | |
Merge branch 'daurnimator-ctx-getStore'
| -rw-r--r-- | src/openssl.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c index 8af1d3d..c33d934 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
| @@ -281,6 +281,10 @@ | |||
| 281 | #define HAVE_X509_STORE_REFERENCES (!OPENSSL_PREREQ(1,1,0)) | 281 | #define HAVE_X509_STORE_REFERENCES (!OPENSSL_PREREQ(1,1,0)) |
| 282 | #endif | 282 | #endif |
| 283 | 283 | ||
| 284 | #ifndef HAVE_X509_STORE_UP_REF | ||
| 285 | #define HAVE_X509_STORE_UP_REF OPENSSL_PREREQ(1,1,0) | ||
| 286 | #endif | ||
| 287 | |||
| 284 | #ifndef HAVE_X509_UP_REF | 288 | #ifndef HAVE_X509_UP_REF |
| 285 | #define HAVE_X509_UP_REF OPENSSL_PREREQ(1,1,0) | 289 | #define HAVE_X509_UP_REF OPENSSL_PREREQ(1,1,0) |
| 286 | #endif | 290 | #endif |
| @@ -1625,6 +1629,18 @@ static void compat_init_X509_STORE_onfree(void *store, void *data NOTUSED, CRYPT | |||
| 1625 | compat.tmp.store = NULL; | 1629 | compat.tmp.store = NULL; |
| 1626 | } /* compat_init_X509_STORE_onfree() */ | 1630 | } /* compat_init_X509_STORE_onfree() */ |
| 1627 | 1631 | ||
| 1632 | #if !HAVE_X509_STORE_UP_REF | ||
| 1633 | #define X509_STORE_up_ref(...) compat_X509_STORE_up_ref(__VA_ARGS__) | ||
| 1634 | |||
| 1635 | static int compat_X509_STORE_up_ref(X509_STORE *crt) { | ||
| 1636 | /* our caller should already have had a proper reference */ | ||
| 1637 | if (CRYPTO_add(&crt->references, 1, CRYPTO_LOCK_X509_STORE) < 2) | ||
| 1638 | return 0; /* fail */ | ||
| 1639 | |||
| 1640 | return 1; | ||
| 1641 | } /* compat_X509_STORE_up_ref() */ | ||
| 1642 | #endif | ||
| 1643 | |||
| 1628 | #if !HAVE_X509_UP_REF | 1644 | #if !HAVE_X509_UP_REF |
| 1629 | #define X509_up_ref(...) compat_X509_up_ref(__VA_ARGS__) | 1645 | #define X509_up_ref(...) compat_X509_up_ref(__VA_ARGS__) |
| 1630 | 1646 | ||
| @@ -6826,6 +6842,16 @@ static int xs_new(lua_State *L) { | |||
| 6826 | } /* xs_new() */ | 6842 | } /* xs_new() */ |
| 6827 | 6843 | ||
| 6828 | 6844 | ||
| 6845 | static X509_STORE *xs_push(lua_State *L, X509_STORE *store) { | ||
| 6846 | X509_STORE **ud = prepsimple(L, X509_STORE_CLASS); | ||
| 6847 | |||
| 6848 | X509_STORE_up_ref(store); | ||
| 6849 | *ud = store; | ||
| 6850 | |||
| 6851 | return *ud; | ||
| 6852 | } /* xs_push() */ | ||
| 6853 | |||
| 6854 | |||
| 6829 | static int xs_interpose(lua_State *L) { | 6855 | static int xs_interpose(lua_State *L) { |
| 6830 | return interpose(L, X509_STORE_CLASS); | 6856 | return interpose(L, X509_STORE_CLASS); |
| 6831 | } /* xs_interpose() */ | 6857 | } /* xs_interpose() */ |
| @@ -7348,6 +7374,20 @@ static int sx_setStore(lua_State *L) { | |||
| 7348 | } /* sx_setStore() */ | 7374 | } /* sx_setStore() */ |
| 7349 | 7375 | ||
| 7350 | 7376 | ||
| 7377 | static int sx_getStore(lua_State *L) { | ||
| 7378 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); | ||
| 7379 | X509_STORE *store; | ||
| 7380 | |||
| 7381 | if((store = SSL_CTX_get_cert_store(ctx))) { | ||
| 7382 | xs_push(L, store); | ||
| 7383 | } else { | ||
| 7384 | lua_pushnil(L); | ||
| 7385 | } | ||
| 7386 | |||
| 7387 | return 1; | ||
| 7388 | } /* sx_getStore() */ | ||
| 7389 | |||
| 7390 | |||
| 7351 | static int sx_setVerify(lua_State *L) { | 7391 | static int sx_setVerify(lua_State *L) { |
| 7352 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); | 7392 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); |
| 7353 | int mode = luaL_optint(L, 2, -1); | 7393 | int mode = luaL_optint(L, 2, -1); |
| @@ -7614,6 +7654,7 @@ static const auxL_Reg sx_methods[] = { | |||
| 7614 | { "getOptions", &sx_getOptions }, | 7654 | { "getOptions", &sx_getOptions }, |
| 7615 | { "clearOptions", &sx_clearOptions }, | 7655 | { "clearOptions", &sx_clearOptions }, |
| 7616 | { "setStore", &sx_setStore }, | 7656 | { "setStore", &sx_setStore }, |
| 7657 | { "getStore", &sx_getStore }, | ||
| 7617 | { "setVerify", &sx_setVerify }, | 7658 | { "setVerify", &sx_setVerify }, |
| 7618 | { "getVerify", &sx_getVerify }, | 7659 | { "getVerify", &sx_getVerify }, |
| 7619 | { "setCertificate", &sx_setCertificate }, | 7660 | { "setCertificate", &sx_setCertificate }, |
