From 6df1ef03b203bab6d25103629958340a4440f753 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Wed, 13 Apr 2016 18:38:37 +0900 Subject: engine: remove OpenSSL::Engine.cleanup as ENGINE_cleanup() is removed in OpenSSL 1.1.0 --- ext/openssl/extconf.rb | 1 - ext/openssl/ossl_engine.c | 37 ++++++++++--------------------------- test/openssl/test_engine.rb | 21 ++++++++++----------- 3 files changed, 20 insertions(+), 39 deletions(-) diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index c231e7f206..614288138c 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -148,7 +148,6 @@ if have_header("openssl/engine.h") have_func("ENGINE_load_openbsd_dev_crypto") have_func("ENGINE_get_digest") have_func("ENGINE_get_cipher") - have_func("ENGINE_cleanup") have_func_or_macro("ENGINE_load_dynamic", "openssl/engine.h") have_func_or_macro("ENGINE_load_4758cca", "openssl/engine.h") have_func_or_macro("ENGINE_load_aep", "openssl/engine.h") diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c index 890ec724e5..1baa291341 100644 --- a/ext/openssl/ossl_engine.c +++ b/ext/openssl/ossl_engine.c @@ -50,14 +50,6 @@ VALUE eEngineError; /* * Private */ -#define OSSL_ENGINE_LOAD_IF_MATCH(x) \ -do{\ - if(!strcmp(#x, RSTRING_PTR(name))){\ - ENGINE_load_##x();\ - return Qtrue;\ - }\ -}while(0) - static void ossl_engine_free(void *engine) { @@ -97,7 +89,17 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass) return Qtrue; } StringValue(name); + #ifndef OPENSSL_NO_STATIC_ENGINE + +/* use old (-1.0.2) ENGINE_load_*() for now */ +#define OSSL_ENGINE_LOAD_IF_MATCH(x) do {\ + if (!strcmp(#x, RSTRING_PTR(name))) {\ + ENGINE_load_##x();\ + return Qtrue;\ + }\ +} while(0) + #if HAVE_ENGINE_LOAD_DYNAMIC OSSL_ENGINE_LOAD_IF_MATCH(dynamic); #endif @@ -153,24 +155,6 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass) #endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */ } -/* Document-method: OpenSSL::Engine.cleanup - * call-seq: - * OpenSSL::Engine.cleanup - * - * It is only necessary to run cleanup when engines are loaded via - * OpenSSL::Engine.load. However, running cleanup before exit is recommended. - * - * See also, https://www.openssl.org/docs/crypto/engine.html - */ -static VALUE -ossl_engine_s_cleanup(VALUE self) -{ -#if defined(HAVE_ENGINE_CLEANUP) - ENGINE_cleanup(); -#endif - return Qnil; -} - /* Document-method: OpenSSL::Engine.engines * * Returns an array of currently loaded engines. @@ -558,7 +542,6 @@ Init_ossl_engine(void) rb_define_alloc_func(cEngine, ossl_engine_s_alloc); rb_define_singleton_method(cEngine, "load", ossl_engine_s_load, -1); - rb_define_singleton_method(cEngine, "cleanup", ossl_engine_s_cleanup, 0); rb_define_singleton_method(cEngine, "engines", ossl_engine_s_engines, 0); rb_define_singleton_method(cEngine, "by_id", ossl_engine_s_by_id, 1); rb_undef_method(CLASS_OF(cEngine), "new"); diff --git a/test/openssl/test_engine.rb b/test/openssl/test_engine.rb index 3521de6396..d4945b1160 100644 --- a/test/openssl/test_engine.rb +++ b/test/openssl/test_engine.rb @@ -3,21 +3,20 @@ require_relative 'utils' class OpenSSL::TestEngine < Test::Unit::TestCase - def teardown - OpenSSL::Engine.cleanup # [ruby-core:40669] - assert_equal(0, OpenSSL::Engine.engines.size) - end - def test_engines_free # [ruby-dev:44173] - OpenSSL::Engine.load("openssl") - OpenSSL::Engine.engines - OpenSSL::Engine.engines + assert_separately(["-ropenssl"], <<-'end;') + OpenSSL::Engine.load("openssl") + OpenSSL::Engine.engines + OpenSSL::Engine.engines + end; end def test_openssl_engine_builtin - engine = OpenSSL::Engine.load("openssl") - assert_equal(true, engine) - assert_equal(1, OpenSSL::Engine.engines.size) + assert_separately(["-ropenssl"], <<-'end;') + engine = OpenSSL::Engine.load("openssl") + assert_equal(true, engine) + assert_equal(1, OpenSSL::Engine.engines.size) + end; end def test_openssl_engine_by_id_string -- cgit v1.2.3