aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-08-31 23:21:58 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-09-02 23:44:32 +0900
commit98a3106539bec4bcb895b0f3ccfc19d77b78edfc (patch)
treea591509f7f1167a7982b5f444f71aba09c05d2f5 /lib
parent25e2d4e981a3461268021f80edc40a5d79ff2466 (diff)
downloadruby-openssl-98a3106539bec4bcb895b0f3ccfc19d77b78edfc.tar.gz
ssl: eliminate SSLContext::INIT_VARStopic/ssl-eliminate-init-vars
Use rb_attr_get() instead of rb_iv_get() so that we can remove SSLContext::INIT_VARS. SSLContext::INIT_VARS contains the names of the instance variables used in SSLContext. SSLContext#initialize sets nil for those variables. It is necessary to suppress "instance variable @foo not initialized" warnings emitted by rb_iv_get(). The warnings can be avoided by using rb_attr_get() that does not check the existence of the variable. So use it.
Diffstat (limited to 'lib')
-rw-r--r--lib/openssl/ssl.rb16
1 files changed, 2 insertions, 14 deletions
diff --git a/lib/openssl/ssl.rb b/lib/openssl/ssl.rb
index 519ea11a..190f5042 100644
--- a/lib/openssl/ssl.rb
+++ b/lib/openssl/ssl.rb
@@ -73,16 +73,6 @@ module OpenSSL
DEFAULT_CERT_STORE.set_default_paths
DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
- # :nodoc:
- INIT_VARS = ["cert", "key", "client_ca", "ca_file", "ca_path",
- "timeout", "verify_mode", "verify_depth", "renegotiation_cb",
- "verify_callback", "cert_store", "extra_chain_cert",
- "client_cert_cb", "session_id_context", "tmp_dh_callback",
- "session_get_cb", "session_new_cb", "session_remove_cb",
- "tmp_ecdh_callback", "servername_cb", "npn_protocols",
- "alpn_protocols", "alpn_select_cb",
- "npn_select_cb", "verify_hostname"].map { |x| "@#{x}" }
-
# A callback invoked when DH parameters are required.
#
# The callback is invoked with the Session for the key exchange, an
@@ -110,10 +100,8 @@ module OpenSSL
#
# You can get a list of valid methods with OpenSSL::SSL::SSLContext::METHODS
def initialize(version = nil)
- INIT_VARS.each { |v| instance_variable_set v, nil }
- self.options = self.options | OpenSSL::SSL::OP_ALL
- return unless version
- self.ssl_version = version
+ self.options |= OpenSSL::SSL::OP_ALL
+ self.ssl_version = version if version
end
##