"Bruce (Riji) Cai" <bcai-zm9q81nvl4ufkj6hysv...@public.gmane.org>
writes:

> Not quite sure, but to my understand, the "ex_data" is saved into per
> ssl connection context, so the index to it should be per connection
> scope.

That's not correct, no. The ex_data mechanism can be used to store many
different things into each SSL connection (similarly for other
structures). Each such kind of thing can get its own index using
SSL_get_ex_new_index, and so each can work independently on the same
connection without interference.

SSL_get_ex_new_index is giving an index for all SSL objects, not any
specific one---it's a global operation.

> While from my observation, the returned index is increased when
> SSL_get_ex_new_index is called once, no matter called by A connection
> or B connection.
>
> In some case, I have only one private data, and I don't want to pass
> the index var to every piece of code,

So use a global of some sort (file static or whatever). I don't see the
problem.

> so can I just save the ex_data directly to index 0 and get it out from
> 0 when needed?

You can, and maybe it'll be OK, but you risk conflicts if something else
in your application also wants to use the ex_data mechanism on
SSLs. Using SSL_get_ex_new_index correctly removes that possible problem
(presuming the other code is also using it correctly, of course).

[...]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to