From 7276233e1ade65465aa89b8b777ebe05608a1468 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Fri, 21 Aug 2020 17:33:25 +0900 Subject: [PATCH] ossl.c: do not set locking callbacks on LibreSSL Similarly to OpenSSL >= 1.1.0, LibreSSL 2.9.0 ensures thread safety without requiring applications to set locking callbacks and made related functions no-op. --- ext/openssl/extconf.rb | 1 - ext/openssl/ossl.c | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index 73a4cdc3b..bd7c5770d 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -130,7 +130,6 @@ def find_openssl_library if !have_struct_member("SSL", "ctx", "openssl/ssl.h") || is_libressl $defs.push("-DHAVE_OPAQUE_OPENSSL") end -have_func("CRYPTO_lock") || $defs.push("-DHAVE_OPENSSL_110_THREADING_API") have_func("BN_GENCB_new") have_func("BN_GENCB_free") have_func("BN_GENCB_get_arg") diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 7bdf3a2ef..cb084cd90 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -9,7 +9,13 @@ */ #include "ossl.h" #include /* for ossl_raise */ -#include /* for OpenSSL < 1.1.0 locks */ + +/* OpenSSL >= 1.1.0 and LibreSSL >= 2.9.0 */ +#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER >= 0x10100000 +# define HAVE_OPENSSL_110_THREADING_API +#else +# include +#endif /* * Data Conversion