Preferred way of passing user context void* inside SSL*

Viktor Dukhovni openssl-users at dukhovni.org
Wed Oct 23 15:57:55 UTC 2019


On Wed, Oct 23, 2019 at 01:21:54PM +0000, Salz, Rich via openssl-users wrote:

> >    Is there a way for me to piggyback a void* inside the SSL structure so
>     that I can access it from within the callback?
>   
> Yes, you can use SSL_set_app_data and SSL_get_app_data which are documented
> in https://github.com/openssl/openssl/pull/10216 (and due to be merged to
> master soon)

If the data is needed by a *library* and not "the application",
then it is not appropriate to use index 0, which is reserved for
"the application".  In that case, the library needs to register its
own "ex data index".  Examples can be seen at:

1-time init:  https://github.com/vdukhovni/postfix/blob/master/postfix/src/tls/tls_client.c#L353
Setter usage: https://github.com/vdukhovni/postfix/blob/master/postfix/src/tls/tls_client.c#L977
Getter usage: https://github.com/vdukhovni/postfix/blob/master/postfix/src/tls/tls_client.c#L255

-- 
	Viktor.


More information about the openssl-users mailing list