diff options
| author | William Ahern <william@25thandclement.com> | 2016-10-29 15:13:43 -0700 |
|---|---|---|
| committer | William Ahern <william@25thandclement.com> | 2016-10-29 15:13:43 -0700 |
| commit | 2ea408fad69bf85df4f3991e91cb0e4dc3727955 (patch) | |
| tree | 494df07c177137607116f0c3deb6541bd9685b55 /src | |
| parent | 20afc608216ab2a09c91626f099e40928bd7fc58 (diff) | |
| download | luaossl-2ea408fad69bf85df4f3991e91cb0e4dc3727955.tar.gz luaossl-2ea408fad69bf85df4f3991e91cb0e4dc3727955.tar.bz2 luaossl-2ea408fad69bf85df4f3991e91cb0e4dc3727955.zip | |
use SSL_client_version
OPENSSL_NO_SSL2 isn't defined even though SSLv2 methods are gone
Diffstat (limited to 'src')
| -rw-r--r-- | src/openssl.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/openssl.c b/src/openssl.c index f05b57a..823bc23 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
| @@ -195,6 +195,10 @@ | |||
| 195 | #define HAVE_RSA_SET0_KEY OPENSSL_PREREQ(1,1,0) | 195 | #define HAVE_RSA_SET0_KEY OPENSSL_PREREQ(1,1,0) |
| 196 | #endif | 196 | #endif |
| 197 | 197 | ||
| 198 | #ifndef HAVE_SSL_CLIENT_VERSION | ||
| 199 | #define HAVE_SSL_CLIENT_VERSION OPENSSL_PREREQ(1,1,0) | ||
| 200 | #endif | ||
| 201 | |||
| 198 | #ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS | 202 | #ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS |
| 199 | #define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,3)) | 203 | #define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,3)) |
| 200 | #endif | 204 | #endif |
| @@ -223,6 +227,14 @@ | |||
| 223 | #define HAVE_SSL_UP_REF OPENSSL_PREREQ(1,1,0) | 227 | #define HAVE_SSL_UP_REF OPENSSL_PREREQ(1,1,0) |
| 224 | #endif | 228 | #endif |
| 225 | 229 | ||
| 230 | #ifndef HAVE_SSLV2_CLIENT_METHOD | ||
| 231 | #define HAVE_SSLV2_CLIENT_METHOD (!OPENSSL_PREREQ(1,1,0) && !defined OPENSSL_NO_SSL2) | ||
| 232 | #endif | ||
| 233 | |||
| 234 | #ifndef HAVE_SSLV2_SERVER_METHOD | ||
| 235 | #define HAVE_SSLV2_SERVER_METHOD (!OPENSSL_PREREQ(1,1,0) && !defined OPENSSL_NO_SSL2) | ||
| 236 | #endif | ||
| 237 | |||
| 226 | #ifndef HAVE_X509_STORE_REFERENCES | 238 | #ifndef HAVE_X509_STORE_REFERENCES |
| 227 | #define HAVE_X509_STORE_REFERENCES (!OPENSSL_PREREQ(1,1,0)) | 239 | #define HAVE_X509_STORE_REFERENCES (!OPENSSL_PREREQ(1,1,0)) |
| 228 | #endif | 240 | #endif |
| @@ -1443,6 +1455,14 @@ static void compat_RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { | |||
| 1443 | } /* compat_RSA_set0_key() */ | 1455 | } /* compat_RSA_set0_key() */ |
| 1444 | #endif | 1456 | #endif |
| 1445 | 1457 | ||
| 1458 | #if !HAVE_SSL_CLIENT_VERSION | ||
| 1459 | #define SSL_client_version(...) compat_SSL_client_version(__VA_ARGS__) | ||
| 1460 | |||
| 1461 | static int compat_SSL_client_version(const SSL *ssl) { | ||
| 1462 | return ssl->client_version; | ||
| 1463 | } /* compat_SSL_client_version() */ | ||
| 1464 | #endif | ||
| 1465 | |||
| 1446 | #if !HAVE_SSL_UP_REF | 1466 | #if !HAVE_SSL_UP_REF |
| 1447 | #define SSL_up_ref(...) compat_SSL_up_ref(__VA_ARGS__) | 1467 | #define SSL_up_ref(...) compat_SSL_up_ref(__VA_ARGS__) |
| 1448 | 1468 | ||
| @@ -7077,7 +7097,7 @@ static int sx_new(lua_State *L) { | |||
| 7077 | method = (srv)? &SSLv23_server_method : &SSLv23_client_method; | 7097 | method = (srv)? &SSLv23_server_method : &SSLv23_client_method; |
| 7078 | options = SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3; | 7098 | options = SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3; |
| 7079 | break; | 7099 | break; |
| 7080 | #ifndef OPENSSL_NO_SSL2 | 7100 | #if HAVE_SSLV2_CLIENT_METHOD && HAVE_SSLV2_SERVER_METHOD |
| 7081 | case 2: /* SSLv2 */ | 7101 | case 2: /* SSLv2 */ |
| 7082 | method = (srv)? &SSLv2_server_method : &SSLv2_client_method; | 7102 | method = (srv)? &SSLv2_server_method : &SSLv2_client_method; |
| 7083 | break; | 7103 | break; |
| @@ -7700,7 +7720,7 @@ static int ssl_getVersion(lua_State *L) { | |||
| 7700 | static int ssl_getClientVersion(lua_State *L) { | 7720 | static int ssl_getClientVersion(lua_State *L) { |
| 7701 | SSL *ssl = checksimple(L, 1, SSL_CLASS); | 7721 | SSL *ssl = checksimple(L, 1, SSL_CLASS); |
| 7702 | int format = luaL_checkoption(L, 2, "d", (const char *[]){ "d", ".", "f", NULL }); | 7722 | int format = luaL_checkoption(L, 2, "d", (const char *[]){ "d", ".", "f", NULL }); |
| 7703 | int version = ssl->client_version; | 7723 | int version = SSL_client_version(ssl); |
| 7704 | int major, minor; | 7724 | int major, minor; |
| 7705 | 7725 | ||
| 7706 | switch (format) { | 7726 | switch (format) { |
