Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

OpenSSL::Config#[]

(::String section) -> ::Hash[::String, ::String]
config[section] → hash

Gets all key-value pairs in a specific section from the current configuration.

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 hash of the specific section like so:

Example
config['default']
  #=> {"foo"=>"bar"}
See also .parse_config #each .parse #get_value also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0