aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2020-02-21 18:38:53 +0900
committerGitHub <noreply@github.com>2020-02-21 18:38:53 +0900
commit325aae1dc4cbcb18071d9069c019af9db89de081 (patch)
treeaf83ea5aff821b14f1be8cecde2f30790592ecf7 /lib
parentf067ed774de5f9e4bdf58063ee6e0f07faad2173 (diff)
parent8ba680a05568b4ab7d7749f68609a8620fa521f7 (diff)
downloadruby-openssl-325aae1dc4cbcb18071d9069c019af9db89de081.tar.gz
Merge pull request #322 from rhenium/ky/config-deprecate-modify
config: deprecate OpenSSL::Config#add_value and #[]=
Diffstat (limited to 'lib')
-rw-r--r--lib/openssl/config.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/openssl/config.rb b/lib/openssl/config.rb
index ef83c57b..c5432ebb 100644
--- a/lib/openssl/config.rb
+++ b/lib/openssl/config.rb
@@ -37,7 +37,7 @@ module OpenSSL
def parse(string)
c = new()
parse_config(StringIO.new(string)).each do |section, hash|
- c[section] = hash
+ c.set_section(section, hash)
end
c
end
@@ -248,7 +248,7 @@ module OpenSSL
if filename
File.open(filename.to_s) do |file|
Config.parse_config(file).each do |section, hash|
- self[section] = hash
+ set_section(section, hash)
end
end
end
@@ -297,6 +297,8 @@ module OpenSSL
end
##
+ # *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:
@@ -351,6 +353,8 @@ module OpenSSL
end
##
+ # *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:
@@ -376,9 +380,13 @@ module OpenSSL
#
def []=(section, pairs)
check_modify
- @data[section] ||= {}
+ set_section(section, pairs)
+ end
+
+ def set_section(section, pairs) # :nodoc:
+ hash = @data[section] ||= {}
pairs.each do |key, value|
- self.add_value(section, key, value)
+ hash[key] = value
end
end
@@ -463,6 +471,8 @@ module OpenSSL
end
def check_modify
+ warn "#{caller(2, 1)[0]}: warning: do not modify OpenSSL::Config; this " \
+ "method is deprecated and will be removed in a future release."
raise TypeError.new("Insecure: can't modify OpenSSL config") if frozen?
end