diff options
author | rhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-05 12:46:05 +0000 |
---|---|---|
committer | rhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-05 12:46:05 +0000 |
commit | e478bb7d79773651fe4339e930aa936c8ae98066 (patch) | |
tree | ee456018af9212a5a21ef52d47413802690d6947 /ext/openssl/ossl.c | |
parent | 9199bec9e85efdcead79cfb19f867e87bb9f48b9 (diff) | |
download | ruby-e478bb7d79773651fe4339e930aa936c8ae98066.tar.gz |
openssl: support OpenSSL 1.1.0's new multi-threading API
* ext/openssl/extconf.rb: Check absence of CRYPTO_lock() to see if the
OpenSSL has the new threading API. In OpenSSL <= 1.0.2, an application
had to set locking callbacks to use OpenSSL in a multi-threaded
environment. OpenSSL 1.1.0 now finds pthreads or Windows threads so we
don't need to do something special.
[ruby-core:75225] [Feature #12324]
Also check existence of *_up_ref(). Some structures in OpenSSL have
a reference counter. We used to increment it with CRYPTO_add() which
is a part of the old API.
* ext/openssl/openssl_missing.h: Implement *_up_ref() if missing.
* ext/openssl/ossl.c: Don't set locking callbacks if unneeded.
* ext/openssl/ossl_pkey.c, ext/openssl/ossl_ssl.c,
ext/openssl/ossl_x509cert.c, ext/openssl/ossl_x509crl.c,
ext/openssl/ossl_x509store.c: Use *_up_ref() instead of CRYPTO_add().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl.c')
-rw-r--r-- | ext/openssl/ossl.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 3654b1e851..9f92b92893 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -508,6 +508,7 @@ ossl_fips_mode_set(VALUE self, VALUE enabled) #endif } +#if !defined(HAVE_OPENSSL_110_THREADING_API) /** * Stores locks needed for OpenSSL thread safety */ @@ -595,6 +596,7 @@ static void Init_ossl_locks(void) CRYPTO_set_dynlock_lock_callback(ossl_dyn_lock_callback); CRYPTO_set_dynlock_destroy_callback(ossl_dyn_destroy_callback); } +#endif /* !HAVE_OPENSSL_110_THREADING_API */ /* * OpenSSL provides SSL, TLS and general purpose cryptography. It wraps the @@ -1195,7 +1197,9 @@ Init_openssl(void) */ ossl_s_to_der = rb_intern("to_der"); +#if !defined(HAVE_OPENSSL_110_THREADING_API) Init_ossl_locks(); +#endif /* * Init components |