class OpenSSL::Config
Configuration for the openssl library.
Many systemโs installation of openssl library will depend on your system configuration. See the value of OpenSSL::Config::DEFAULT_CONFIG_FILE for the location of the file for your host.
See also docs.openssl.org/master/man5/config/
Constants
- DEFAULT_CONFIG_FILE
-
The default system configuration file for
OpenSSL.
Public Class Methods
(?_ToS filename) → instance
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 2936
def self.load: (?_ToS filename) -> instance
(?_ToS filename) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3130
def initialize: (?_ToS filename) -> void
Creates an instance of OpenSSL::Config from the content of the file specified by filename.
This can be used in contexts like OpenSSL::X509::ExtensionFactory.config=
This can raise IO exceptions based on the access, or availability of the file. A ConfigError exception may be raised depending on the validity of the data being configured.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 2944
def self.parse: (String string) -> instance
Parses a given string as a blob that contains configuration for OpenSSL.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 2953
def self.parse_config: (IO io) -> Hash[String, Hash[String, String]]
Parses the configuration data read from io and returns the whole content as a Hash.
Public Instance Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 2975
def []: (String section) -> Hash[String, String]
Gets all key-value pairs in a specific section from the current configuration.
Given the following configurating file being loaded:
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:
config['default'] #=> {"foo"=>"bar"}
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3006
def []=: (String section, _Each[[ String, String ]] pairs) -> _Each[[ String, String ]]
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:
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:
config['default'] #=> {"foo"=>"bar", "baz"=>"buz"} config['default'] = {"foo" => "changed"} #=> {"foo"=>"changed"} config['default'] #=> {"foo"=>"changed", "baz"=>"buz"}
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3032
def add_value: (String section, untyped key, untyped value) -> untyped
Deprecated in v2.2.0. This method will be removed in a future release.
Set the target key with a given value under a specific section.
Given the following configurating file being loaded:
config = OpenSSL::Config.load('foo.cnf') #=> #<OpenSSL::Config sections=["default"]> puts config.to_s #=> [ default ] # foo=bar
You can set the value of foo under the default section to a new value:
config.add_value('default', 'foo', 'buzz') #=> "buzz" puts config.to_s #=> [ default ] # foo=buzz
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3044
def each: () { ([ String, String, String ] args0) -> void } -> self
Retrieves the section and its pairs for the current configuration.
config.each do |section, key, value| # ... end
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3066
def get_value: (String section, String key) -> String?
Gets the value of key from the given section.
Given the following configurating file being loaded:
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:
config.get_value('default','foo') #=> "bar"
(self other) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3137
def initialize_copy: (self other) -> void
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3075
def inspect: () -> String
String representation of this configuration object, including the class name and its sections.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3077
def section: (String name) -> Hash[String, String]
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3085
def sections: () -> Array[String]
Get the names of all sections in the current configuration.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 3113
def to_s: () -> String
Gets the parsable form of the current configuration.
Given the following configuration file being loaded:
config = OpenSSL::Config.load('baz.cnf') #=> #<OpenSSL::Config sections=["default"]> puts config.to_s #=> [ default ] # foo=bar # baz=buz
You can get the serialized configuration using to_s and then parse it later:
serialized_config = config.to_s # much later... new_config = OpenSSL::Config.parse(serialized_config) #=> #<OpenSSL::Config sections=["default"]> puts new_config #=> [ default ] foo=bar baz=buz