Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

OpenSSL::Config#[]=

[]=(section, pairs)

*Deprecated in v2.2.0*. This method will be removed in a future release.

Sets a specific section name with a Hash pairs.

Given the following configuration being created:

Example
config = OpenSSL::Config.new
  #=> #<OpenSSL::Config sections=[]>
config['default'] = {"foo"=>"bar","baz"=>"buz"}
  #=> {"foo"=>"bar", "baz"=>"buz"}
puts config.to_s
  #=> [ default ]
  #   foo=bar
  #   baz=buz

It’s important to note that this will essentially merge any of the keys in pairs with the existing section. For example:

Example
config['default']
  #=> {"foo"=>"bar", "baz"=>"buz"}
config['default'] = {"foo" => "changed"}
  #=> {"foo"=>"changed"}
config['default']
  #=> {"foo"=>"changed", "baz"=>"buz"}