diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/openssl.c b/src/openssl.c index d64777f..2b0cb88 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
@@ -83,6 +83,14 @@ | |||
83 | #include "compat52.h" | 83 | #include "compat52.h" |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | #ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS | ||
87 | #define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_VERSION_NUMBER >= 0x1000200fL) | ||
88 | #endif | ||
89 | |||
90 | #ifndef HAVE_SSL_GET0_ALPN_SELECTED | ||
91 | #define HAVE_SSL_GET0_ALPN_SELECTED HAVE_SSL_CTX_SET_ALPN_PROTOS | ||
92 | #endif | ||
93 | |||
86 | #define BIGNUM_CLASS "BIGNUM*" | 94 | #define BIGNUM_CLASS "BIGNUM*" |
87 | #define PKEY_CLASS "EVP_PKEY*" | 95 | #define PKEY_CLASS "EVP_PKEY*" |
88 | #define X509_NAME_CLASS "X509_NAME*" | 96 | #define X509_NAME_CLASS "X509_NAME*" |
@@ -4516,6 +4524,7 @@ static int sx_setEphemeralKey(lua_State *L) { | |||
4516 | return 1; | 4524 | return 1; |
4517 | } /* sx_setEphemeralKey() */ | 4525 | } /* sx_setEphemeralKey() */ |
4518 | 4526 | ||
4527 | #if HAVE_SSL_CTX_SET_ALPN_PROTOS | ||
4519 | static int sx_setAlpnProtos(lua_State *L) { | 4528 | static int sx_setAlpnProtos(lua_State *L) { |
4520 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); | 4529 | SSL_CTX *ctx = checksimple(L, 1, SSL_CTX_CLASS); |
4521 | size_t len; | 4530 | size_t len; |
@@ -4553,7 +4562,8 @@ done: | |||
4553 | lua_pushboolean(L, 1); | 4562 | lua_pushboolean(L, 1); |
4554 | 4563 | ||
4555 | return 1; | 4564 | return 1; |
4556 | } /* sx_setAlpnprotos */ | 4565 | } /* sx_setAlpnProtos() */ |
4566 | #endif | ||
4557 | 4567 | ||
4558 | static int sx__gc(lua_State *L) { | 4568 | static int sx__gc(lua_State *L) { |
4559 | SSL_CTX **ud = luaL_checkudata(L, 1, SSL_CTX_CLASS); | 4569 | SSL_CTX **ud = luaL_checkudata(L, 1, SSL_CTX_CLASS); |
@@ -4578,7 +4588,9 @@ static const luaL_Reg sx_methods[] = { | |||
4578 | { "setPrivateKey", &sx_setPrivateKey }, | 4588 | { "setPrivateKey", &sx_setPrivateKey }, |
4579 | { "setCipherList", &sx_setCipherList }, | 4589 | { "setCipherList", &sx_setCipherList }, |
4580 | { "setEphemeralKey", &sx_setEphemeralKey }, | 4590 | { "setEphemeralKey", &sx_setEphemeralKey }, |
4591 | #if HAVE_SSL_CTX_SET_ALPN_PROTOS | ||
4581 | { "setAlpnProtos", &sx_setAlpnProtos }, | 4592 | { "setAlpnProtos", &sx_setAlpnProtos }, |
4593 | #endif | ||
4582 | { NULL, NULL }, | 4594 | { NULL, NULL }, |
4583 | }; | 4595 | }; |
4584 | 4596 | ||
@@ -4829,6 +4841,7 @@ static int ssl_getClientVersion(lua_State *L) { | |||
4829 | return 1; | 4841 | return 1; |
4830 | } /* ssl_getClientVersion() */ | 4842 | } /* ssl_getClientVersion() */ |
4831 | 4843 | ||
4844 | #if HAVE_SSL_GET0_ALPN_SELECTED | ||
4832 | static int ssl_getAlpnSelected(lua_State *L) { | 4845 | static int ssl_getAlpnSelected(lua_State *L) { |
4833 | SSL *ssl = checksimple(L, 1, SSL_CLASS); | 4846 | SSL *ssl = checksimple(L, 1, SSL_CLASS); |
4834 | const unsigned char *data; | 4847 | const unsigned char *data; |
@@ -4840,7 +4853,8 @@ static int ssl_getAlpnSelected(lua_State *L) { | |||
4840 | lua_pushlstring(L, (const char *)data, len); | 4853 | lua_pushlstring(L, (const char *)data, len); |
4841 | } | 4854 | } |
4842 | return 1; | 4855 | return 1; |
4843 | } /*ssl_getAlpnSelected */ | 4856 | } /* ssl_getAlpnSelected() */ |
4857 | #endif | ||
4844 | 4858 | ||
4845 | static int ssl__gc(lua_State *L) { | 4859 | static int ssl__gc(lua_State *L) { |
4846 | SSL **ud = luaL_checkudata(L, 1, SSL_CLASS); | 4860 | SSL **ud = luaL_checkudata(L, 1, SSL_CLASS); |
@@ -4865,7 +4879,9 @@ static const luaL_Reg ssl_methods[] = { | |||
4865 | { "setHostName", &ssl_setHostName }, | 4879 | { "setHostName", &ssl_setHostName }, |
4866 | { "getVersion", &ssl_getVersion }, | 4880 | { "getVersion", &ssl_getVersion }, |
4867 | { "getClientVersion", &ssl_getClientVersion }, | 4881 | { "getClientVersion", &ssl_getClientVersion }, |
4882 | #if HAVE_SSL_GET0_ALPN_SELECTED | ||
4868 | { "getAlpnSelected", &ssl_getAlpnSelected }, | 4883 | { "getAlpnSelected", &ssl_getAlpnSelected }, |
4884 | #endif | ||
4869 | { NULL, NULL }, | 4885 | { NULL, NULL }, |
4870 | }; | 4886 | }; |
4871 | 4887 | ||