[openssl-dev] ssl_sess.c : compilation error

Kurt Roeckx kurt at roeckx.be
Sun Jun 7 20:16:24 UTC 2015


On Sun, Jun 07, 2015 at 09:36:20PM +0300, Zvi Vered wrote:
> Hi Kurt,
> 
> I think I have a C problem.
> 
> I do not understand how the compiler enable to use the pointer ctx.
> ctx is not declared in the routine parameters nor in the routine body.

As I already explained, ctx *is* the only parameter to the
function.

Rewriting that code with a typedef could look like:
typedef int (*session_cb_type)(SSL *ssl, SSL_SESSION *sess);
session_cb_type SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)
{
        return ctx->new_session_cb;
}

That does exactly the same thing.

> What is the purpose of:
> int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(SSL *ssl, SSL_SESSION *sess)
>    {
>     return ctx->new_session_cb;
>     }
> 
> Is it part of the ssl infrastructure or for external user who links with ssl
> library ?

You can set a callback on the creation of a new session.  See the
SSL_CTX_sess_set_new_cb() manpage.  The SSL_CTX_sess_get_new_cb()
get function returns that callback function back.

There are no internal users in OpenSSL as far as I can see.  There
might be code using OpenSSL that uses it, but I don't think that's
very likely.


Kurt



More information about the openssl-dev mailing list