[前][次][番号順一覧][スレッド一覧]

ruby-changes:39376

From: tenderlove <ko1@a...>
Date: Sat, 1 Aug 2015 03:29:22 +0900 (JST)
Subject: [ruby-changes:39376] tenderlove:r51457 (trunk): * ext/openssl/ossl_ssl.c (ossl_call_tmp_ecdh_callback): The SSL socket

tenderlove	2015-08-01 03:29:12 +0900 (Sat, 01 Aug 2015)

  New Revision: 51457

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51457

  Log:
    * ext/openssl/ossl_ssl.c (ossl_call_tmp_ecdh_callback): The SSL socket
      always holds a reference to the SSLContext object, which will have
      the callback object.  Ask the context for the callback instead of
      storing the callback in two places.

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/ossl_ssl.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51456)
+++ ChangeLog	(revision 51457)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Aug  1 03:27:12 2015  Aaron Patterson <tenderlove@r...>
+
+	* ext/openssl/ossl_ssl.c (ossl_call_tmp_ecdh_callback): The SSL socket
+	  always holds a reference to the SSLContext object, which will have
+	  the callback object.  Ask the context for the callback instead of
+	  storing the callback in two places.
+
 Sat Aug  1 03:14:07 2015  Aaron Patterson <tenderlove@r...>
 
 	* ext/openssl/lib/openssl/ssl.rb (module OpenSSL): convert
Index: ext/openssl/ossl_ssl.c
===================================================================
--- ext/openssl/ossl_ssl.c	(revision 51456)
+++ ext/openssl/ossl_ssl.c	(revision 51457)
@@ -139,7 +139,6 @@ int ossl_ssl_ex_store_p; https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L139
 int ossl_ssl_ex_ptr_idx;
 int ossl_ssl_ex_client_cert_cb_idx;
 int ossl_ssl_ex_tmp_dh_callback_idx;
-int ossl_ssl_ex_tmp_ecdh_callback_idx;
 
 static void
 ossl_sslctx_free(void *ptr)
@@ -288,12 +287,12 @@ ossl_tmp_dh_callback(SSL *ssl, int is_ex https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L287
 static VALUE
 ossl_call_tmp_ecdh_callback(VALUE args)
 {
-    SSL *ssl;
-    VALUE cb, ecdh;
+    VALUE cb, ecdh, ctx;
     EVP_PKEY *pkey;
 
-    GetSSL(rb_ary_entry(args, 0), ssl);
-    cb = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_tmp_ecdh_callback_idx);
+    ctx = rb_funcall(rb_ary_entry(args, 0), rb_intern("context"), 0);
+    cb = rb_funcall(ctx, rb_intern("tmp_ecdh_callback"), 0);
+
     if (NIL_P(cb)) return Qfalse;
     ecdh = rb_apply(cb, rb_intern("call"), args);
     pkey = GetPKeyPtr(ecdh);
@@ -1259,8 +1258,6 @@ ossl_ssl_setup(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1258
 	SSL_set_ex_data(ssl, ossl_ssl_ex_client_cert_cb_idx, (void*)cb);
 	cb = ossl_sslctx_get_tmp_dh_cb(v_ctx);
 	SSL_set_ex_data(ssl, ossl_ssl_ex_tmp_dh_callback_idx, (void*)cb);
-	cb = ossl_sslctx_get_tmp_ecdh_cb(v_ctx);
-	SSL_set_ex_data(ssl, ossl_ssl_ex_tmp_ecdh_callback_idx, (void*)cb);
 	SSL_set_info_callback(ssl, ssl_info_cb);
     }
 
@@ -1978,8 +1975,6 @@ Init_ossl_ssl(void) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1975
 	SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_client_cert_cb_idx",0,0,0);
     ossl_ssl_ex_tmp_dh_callback_idx =
 	SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_tmp_dh_callback_idx",0,0,0);
-    ossl_ssl_ex_tmp_ecdh_callback_idx =
-	SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_tmp_ecdh_callback_idx",0,0,0);
 
     /* Document-module: OpenSSL::SSL
      *

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]