diff options
author | Kazuki Yamaguchi <[email protected]> | 2020-02-19 05:11:54 +0000 |
---|---|---|
committer | Kazuki Yamaguchi <[email protected]> | 2021-03-16 19:16:10 +0900 |
commit | 10289e9f229dae499d8f9c4e8252aeb728117d28 (patch) | |
tree | 828613bdc0a6739b73924c08d2cdda447d9e176b /ext/openssl/ossl_config.c | |
parent | 22aeb6373e13929e80da1676b1dc79cbfffc38a4 (diff) |
[ruby/openssl] config: replace DupConfigPtr() with GetConfig()
Now that OpenSSL::Config wraps a real CONF object, the caller can just
borrow it rather than creating a new temporary CONF object. CONF object
is usually treated as immutable.
DupConfigPtr() is now removed, and GetConfig() is exported instead.
https://github.com/ruby/openssl/commit/d9064190ca
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4275
Diffstat (limited to 'ext/openssl/ossl_config.c')
-rw-r--r-- | ext/openssl/ossl_config.c | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/ext/openssl/ossl_config.c b/ext/openssl/ossl_config.c index 52d96e1ed1..21c327b26b 100644 --- a/ext/openssl/ossl_config.c +++ b/ext/openssl/ossl_config.c @@ -25,7 +25,7 @@ static const rb_data_type_t ossl_config_type = { 0, 0, RUBY_TYPED_FREE_IMMEDIATELY, }; -static CONF * +CONF * GetConfig(VALUE obj) { CONF *conf; @@ -50,42 +50,6 @@ config_s_alloc(VALUE klass) return obj; } -/* - * DupConfigPtr is a public C-level function for getting OpenSSL CONF struct - * from an OpenSSL::Config(eConfig) instance. We decided to implement - * OpenSSL::Config in Ruby level but we need to pass native CONF struct for - * some OpenSSL features such as X509V3_EXT_*. - */ -CONF * -DupConfigPtr(VALUE obj) -{ - CONF *conf; - VALUE str; - BIO *bio; - long eline = -1; - - OSSL_Check_Kind(obj, cConfig); - str = rb_funcall(obj, rb_intern("to_s"), 0); - bio = ossl_obj2bio(&str); - conf = NCONF_new(NULL); - if(!conf){ - BIO_free(bio); - ossl_raise(eConfigError, NULL); - } - if(!NCONF_load_bio(conf, bio, &eline)){ - BIO_free(bio); - NCONF_free(conf); - if (eline <= 0) - ossl_raise(eConfigError, "wrong config format"); - else - ossl_raise(eConfigError, "error in line %d", eline); - } - BIO_free(bio); - - return conf; -} - - static void config_load_bio(CONF *conf, BIO *bio) { |