aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-07-20 15:10:06 +1000
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-07-20 15:10:11 +1000
commit099af5e395b843f86694005704111049f22e5d39 (patch)
tree868e8bd1288ca01db1a48aad6cc9e759d66a47f7
parentd19dc1efbab219a1ccd673c7c1da4702332ea3a7 (diff)
downloadluaossl-099af5e395b843f86694005704111049f22e5d39.tar.gz
luaossl-099af5e395b843f86694005704111049f22e5d39.tar.bz2
luaossl-099af5e395b843f86694005704111049f22e5d39.zip
src/openssl.c: Add SSL_CTX_up_ref shim for OpenSSL < 1.1.0
-rw-r--r--src/openssl.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 102408e..c66c270 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -311,6 +311,10 @@
#define HAVE_SSL_CTX_SET1_PARAM (OPENSSL_PREREQ(1,0,2) || LIBRESSL_PREREQ(2,1,0))
#endif
+#ifndef HAVE_SSL_CTX_UP_REF
+#define HAVE_SSL_CTX_UP_REF (OPENSSL_PREREQ(1,1,0) || LIBRESSL_PREREQ(2,7,0))
+#endif
+
#ifndef HAVE_SSL_CTX_CERT_STORE
#define HAVE_SSL_CTX_CERT_STORE (!OPENSSL_PREREQ(1,1,0))
#endif
@@ -1853,6 +1857,18 @@ static int compat_SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm) {
} /* compat_SSL_CTX_set1_param() */
#endif
+#if !HAVE_SSL_CTX_UP_REF
+#define SSL_CTX_up_ref(...) EXPAND( compat_SSL_CTX_up_ref(__VA_ARGS__) )
+
+static int compat_SSL_CTX_up_ref(SSL_CTX *ctx) {
+ /* our caller should already have had a proper reference */
+ if (CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX) < 2)
+ return 0; /* fail */
+
+ return 1;
+} /* compat_SSL_CTX_up_ref() */
+#endif
+
#if !HAVE_STACK_OPENSSL_STRING_FUNCS
#define sk_OPENSSL_STRING_num(s) sk_num(s)
#define sk_OPENSSL_STRING_value(s, i) sk_value((s), (i))