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 @@ #define HAVE_RSA_SET0_KEY OPENSSL_PREREQ(1,1,0) #endif +#ifndef HAVE_SSL_CLIENT_VERSION +#define HAVE_SSL_CLIENT_VERSION OPENSSL_PREREQ(1,1,0) +#endif + #ifndef HAVE_SSL_CTX_SET_ALPN_PROTOS #define HAVE_SSL_CTX_SET_ALPN_PROTOS (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,3)) #endif @@ -223,6 +227,14 @@ #define HAVE_SSL_UP_REF OPENSSL_PREREQ(1,1,0) #endif +#ifndef HAVE_SSLV2_CLIENT_METHOD +#define HAVE_SSLV2_CLIENT_METHOD (!OPENSSL_PREREQ(1,1,0) && !defined OPENSSL_NO_SSL2) +#endif + +#ifndef HAVE_SSLV2_SERVER_METHOD +#define HAVE_SSLV2_SERVER_METHOD (!OPENSSL_PREREQ(1,1,0) && !defined OPENSSL_NO_SSL2) +#endif + #ifndef HAVE_X509_STORE_REFERENCES #define HAVE_X509_STORE_REFERENCES (!OPENSSL_PREREQ(1,1,0)) #endif @@ -1443,6 +1455,14 @@ static void compat_RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { } /* compat_RSA_set0_key() */ #endif +#if !HAVE_SSL_CLIENT_VERSION +#define SSL_client_version(...) compat_SSL_client_version(__VA_ARGS__) + +static int compat_SSL_client_version(const SSL *ssl) { + return ssl->client_version; +} /* compat_SSL_client_version() */ +#endif + #if !HAVE_SSL_UP_REF #define SSL_up_ref(...) compat_SSL_up_ref(__VA_ARGS__) @@ -7077,7 +7097,7 @@ static int sx_new(lua_State *L) { method = (srv)? &SSLv23_server_method : &SSLv23_client_method; options = SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3; break; -#ifndef OPENSSL_NO_SSL2 +#if HAVE_SSLV2_CLIENT_METHOD && HAVE_SSLV2_SERVER_METHOD case 2: /* SSLv2 */ method = (srv)? &SSLv2_server_method : &SSLv2_client_method; break; @@ -7700,7 +7720,7 @@ static int ssl_getVersion(lua_State *L) { static int ssl_getClientVersion(lua_State *L) { SSL *ssl = checksimple(L, 1, SSL_CLASS); int format = luaL_checkoption(L, 2, "d", (const char *[]){ "d", ".", "f", NULL }); - int version = ssl->client_version; + int version = SSL_client_version(ssl); int major, minor; switch (format) { |