Skip to content

Commit 7276233

Browse files
committed
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.
1 parent 3b7d704 commit 7276233

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ext/openssl/extconf.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def find_openssl_library
130130
if !have_struct_member("SSL", "ctx", "openssl/ssl.h") || is_libressl
131131
$defs.push("-DHAVE_OPAQUE_OPENSSL")
132132
end
133-
have_func("CRYPTO_lock") || $defs.push("-DHAVE_OPENSSL_110_THREADING_API")
134133
have_func("BN_GENCB_new")
135134
have_func("BN_GENCB_free")
136135
have_func("BN_GENCB_get_arg")

ext/openssl/ossl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
*/
1010
#include "ossl.h"
1111
#include <stdarg.h> /* for ossl_raise */
12-
#include <ruby/thread_native.h> /* for OpenSSL < 1.1.0 locks */
12+
13+
/* OpenSSL >= 1.1.0 and LibreSSL >= 2.9.0 */
14+
#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER >= 0x10100000
15+
# define HAVE_OPENSSL_110_THREADING_API
16+
#else
17+
# include <ruby/thread_native.h>
18+
#endif
1319

1420
/*
1521
* Data Conversion

0 commit comments

Comments
 (0)