Skip to content

Commit

Permalink
ossl.c: do not set locking callbacks on LibreSSL
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rhenium committed Apr 4, 2021
1 parent 3b7d704 commit 7276233
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 7 additions & 1 deletion ext/openssl/ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
*/
#include "ossl.h"
#include <stdarg.h> /* for ossl_raise */
#include <ruby/thread_native.h> /* 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 <ruby/thread_native.h>
#endif

/*
* Data Conversion
Expand Down

0 comments on commit 7276233

Please sign in to comment.