summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortenderlove <tenderlove@ruby-lang.org>2015-07-25 22:51:20 +0000
committertenderlove <tenderlove@ruby-lang.org>2015-07-25 22:51:20 +0000
commitc9c6d7ac0e8e27a5e586fc9ff44e7a929e2a8898 (patch)
tree523acbbf979d7a30c862b793fd5d56ce31675ebd /lib
parentda67d95f477410370e16383d7a89172f319b75c4 (diff)
downloadruby-openssl-history-c9c6d7ac0e8e27a5e586fc9ff44e7a929e2a8898.tar.gz
* ext/openssl/lib/openssl/ssl.rb (module OpenSSL): move the default
tmp_dh_callback Ruby code and set it as a default in `initialize`. * ext/openssl/ossl_pkey_dh.c (static unsigned char DEFAULT_DH_512_GEN): move this constant to Ruby. * ext/openssl/ossl_pkey_dh.c (static unsigned char DEFAULT_DH_1024_GEN): ditto * ext/openssl/ossl_pkey_dh.c (Init_ossl_dh): ditto * ext/openssl/ossl_ssl.c (ossl_tmp_dh_callback): ditto * ext/openssl/ossl_ssl.c (ossl_sslctx_setup): tmp_dh_callback should always be set, so we can remove this conditional git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/openssl/ssl.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/openssl/ssl.rb b/lib/openssl/ssl.rb
index aef465b..ef2b3f1 100644
--- a/lib/openssl/ssl.rb
+++ b/lib/openssl/ssl.rb
@@ -74,10 +74,24 @@ module OpenSSL
DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
end
+ if defined?(OpenSSL::PKey::DH)
+ DEFAULT_TMP_DH_CALLBACK = lambda { |ctx, is_export, keylen|
+ warn "using default DH parameters." if $VERBOSE
+ case keylen
+ when 512 then OpenSSL::PKey::DH::DEFAULT_512
+ when 1024 then OpenSSL::PKey::DH::DEFAULT_1024
+ else
+ nil
+ end
+ }
+ else
+ DEFAULT_TMP_DH_CALLBACK = nil
+ end
+
INIT_VARS = ["cert", "key", "client_ca", "ca_file", "ca_path",
"timeout", "verify_mode", "verify_depth", "renegotiation_cb",
"verify_callback", "options", "cert_store", "extra_chain_cert",
- "client_cert_cb", "tmp_dh_callback", "session_id_context",
+ "client_cert_cb", "session_id_context",
"session_get_cb", "session_new_cb", "session_remove_cb",
"tmp_ecdh_callback", "servername_cb", "npn_protocols",
"alpn_protocols", "alpn_select_cb",
@@ -91,6 +105,7 @@ 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 }
+ @tmp_dh_callback = DEFAULT_TMP_DH_CALLBACK
return unless version
self.ssl_version = version
end