ruby-changes:39378
From: tenderlove <ko1@a...>
Date: Sat, 1 Aug 2015 03:51:53 +0900 (JST)
Subject: [ruby-changes:39378] tenderlove:r51459 (trunk): * ext/openssl/ossl_ssl.c (ossl_call_tmp_dh_callback): Similarly to the
tenderlove 2015-08-01 03:51:30 +0900 (Sat, 01 Aug 2015) New Revision: 51459 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51459 Log: * ext/openssl/ossl_ssl.c (ossl_call_tmp_dh_callback): Similarly to the tmp_ecdh_callback, the SSLSocket instance always holds a reference to the SSLContext object (it's always set in `initialize`). The SSLContext holds a reference to the tmp_dh_callback. 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 51458) +++ ChangeLog (revision 51459) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Aug 1 03:49:31 2015 Aaron Patterson <tenderlove@r...> + + * ext/openssl/ossl_ssl.c (ossl_call_tmp_dh_callback): Similarly to the + tmp_ecdh_callback, the SSLSocket instance always holds a reference + to the SSLContext object (it's always set in `initialize`). The + SSLContext holds a reference to the tmp_dh_callback. Ask the + context for the callback instead of storing the callback in two + places. + Sat Aug 1 03:43:10 2015 Aaron Patterson <tenderlove@r...> * ext/openssl/ossl_ssl.c (ossl_call_tmp_dh_callback): create an array Index: ext/openssl/ossl_ssl.c =================================================================== --- ext/openssl/ossl_ssl.c (revision 51458) +++ ext/openssl/ossl_ssl.c (revision 51459) @@ -65,7 +65,6 @@ static VALUE eSSLErrorWaitWritable; https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L65 #define ossl_sslctx_get_extra_cert(o) rb_iv_get((o),"@extra_chain_cert") #define ossl_sslctx_get_client_cert_cb(o) rb_iv_get((o),"@client_cert_cb") #define ossl_sslctx_get_tmp_ecdh_cb(o) rb_iv_get((o),"@tmp_ecdh_callback") -#define ossl_sslctx_get_tmp_dh_cb(o) rb_funcall((o),rb_intern("tmp_dh_callback"),0) #define ossl_sslctx_get_sess_id_ctx(o) rb_iv_get((o),"@session_id_context") #define ossl_ssl_get_io(o) rb_iv_get((o),"@io") @@ -138,7 +137,6 @@ int ossl_ssl_ex_vcb_idx; https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L137 int ossl_ssl_ex_store_p; int ossl_ssl_ex_ptr_idx; int ossl_ssl_ex_client_cert_cb_idx; -int ossl_ssl_ex_tmp_dh_callback_idx; static void ossl_sslctx_free(void *ptr) @@ -252,12 +250,12 @@ ossl_client_cert_cb(SSL *ssl, X509 **x50 https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L250 static VALUE ossl_call_tmp_dh_callback(VALUE args) { - SSL *ssl; - VALUE cb, dh; + VALUE cb, dh, ctx; EVP_PKEY *pkey; - GetSSL(rb_ary_entry(args, 0), ssl); - cb = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_tmp_dh_callback_idx); + ctx = rb_funcall(rb_ary_entry(args, 0), rb_intern("context"), 0); + cb = rb_funcall(ctx, rb_intern("tmp_dh_callback"), 0); + if (NIL_P(cb)) return Qfalse; dh = rb_apply(cb, rb_intern("call"), args); pkey = GetPKeyPtr(dh); @@ -1256,8 +1254,6 @@ ossl_ssl_setup(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1254 SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void*)cb); cb = ossl_sslctx_get_client_cert_cb(v_ctx); 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); SSL_set_info_callback(ssl, ssl_info_cb); } @@ -1973,8 +1969,6 @@ Init_ossl_ssl(void) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_ssl.c#L1969 ossl_ssl_ex_ptr_idx = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_ptr_idx",0,0,0); ossl_ssl_ex_client_cert_cb_idx = 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); /* Document-module: OpenSSL::SSL * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/