End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
OpenSSL::Config#get_value
config.get_value(section, key) → string
ext/openssl/ossl_config.c
View on GitHub ↗
static VALUE
config_get_value(VALUE self, VALUE section, VALUE key)
{
CONF *conf = GetConfig(self);
const char *str, *sectionp;
StringValueCStr(section);
StringValueCStr(key);
/* For compatibility; NULL means "default". */
sectionp = RSTRING_LEN(section) ? RSTRING_PTR(section) : NULL;
str = NCONF_get_string(conf, sectionp, RSTRING_PTR(key));
if (!str) {
ossl_clear_error();
return Qnil;
}
return rb_str_new_cstr(str);
}
Gets the value of key from the given section.
Given the following configurating file being loaded:
Example
config = OpenSSL::Config.load('foo.cnf') #=> #<OpenSSL::Config sections=["default"]> puts config.to_s #=> [ default ] # foo=bar
You can get a specific value from the config if you know the section and key like so:
Example
config.get_value('default','foo') #=> "bar"