SSL_CTX_SET_...ION_TICKET_CB(3ossl)
π NAME π
okay bestie, gather round, because this is the session-ticket-appdata saga β¨
SSL_CTX_set_session_ticket_cb, SSL_SESSION_get0_ticket_appdata, SSL_SESSION_set1_ticket_appdata, SSL_CTX_generate_session_ticket_fn, SSL_CTX_decrypt_session_ticket_fn β they're all about managing session ticket application data. that's the whole vibe. π
this is the OpenSSL page, section 3ossl, and yes we're about to get into it.
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
typedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg);
typedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss,
const unsigned char *keyname,
size_t keyname_len,
SSL_TICKET_STATUS status,
void *arg);
int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx,
SSL_CTX_generate_session_ticket_fn gen_cb,
SSL_CTX_decrypt_session_ticket_fn dec_cb,
void *arg);
int SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len);
int SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len);
πΈ DESCRIPTION πΈ
SSL_CTX_set_set_session_ticket_cb() sets the application callbacks gen_cb and dec_cb that a server uses to set and get application data stored with a session, and then placed into a session ticket. either callback can be set to NULL, no pressure. the value of arg gets passed along to both callbacks. π«Ά
gen_cb is the application defined callback that fires when a session ticket is about to be created. right at that moment, your app can call SSL_SESSION_set1_ticket_appdata() to add application data to the session ticket. the value of arg here is the same one you gave to SSL_CTX_set_session_ticket_cb(). and gen_cb is defined as type SSL_CTX_generate_session_ticket_fn. π«
dec_cb is the application defined callback that fires after session ticket decryption has been attempted and any session ticket application data is available. if the ticket decryption worked, then the ss argument holds the session data. the keyname and keyname_len arguments identify the key used to decrypt the session ticket. the status argument is the result of the ticket decryption β peep the "NOTES" section below for the full tea. the value of arg is the same as what you gave to SSL_CTX_set_session_ticket_cb(). and dec_cb is defined as type SSL_CTX_decrypt_session_ticket_fn. π
SSL_SESSION_set1_ticket_appdata() sets the application data specified by data and len into ss, which then gets placed into any generated session tickets. you can call it at any time before a session ticket is created to update the data that goes into the session ticket. but okay, real talk: since sessions and tickets are created by the handshake, the gen_cb exists precisely to ping your application that a session ticket is about to be generated. iconic teamwork tbh. β¨
SSL_SESSION_get0_ticket_appdata() assigns data to the session ticket application data, and assigns len to the length of that session ticket application data from ss. the application data can be set either via SSL_SESSION_set1_ticket_appdata() or by a session ticket. NULL will be assigned to data and 0 will be assigned to len if there's no session ticket application data at all. you can call SSL_SESSION_get0_ticket_appdata() any time after a session has been created. and the dec_cb is the thing that pings your application that a session ticket has just been decrypted. π¦
π NOTES π
when the dec_cb callback is invoked, the SSL_SESSION ss has not yet been assigned to the SSL s. the status tells you the result of the ticket decryption. the callback must check the status value before doing literally anything, because it gets called even if ticket decryption fails. no skipping the vibe check. π
the keyname and keyname_len arguments to dec_cb may be used to identify the key that was used to encrypt the session ticket. π
the status argument can be any of these values:
SSL_TICKET_EMPTYβ empty ticket present. no ticket data will be used and a new ticket should be sent to the client. this only happens in TLSv1.2 or below. in TLSv1.3 it is not valid for a client to send an empty ticket. π«SSL_TICKET_NO_DECRYPTβ the ticket couldn't be decrypted. no ticket data will be used and a new ticket should be sent to the client. πSSL_TICKET_SUCCESSβ a ticket was successfully decrypted, so any session ticket application data should be available. a new ticket should not be sent to the client. βSSL_TICKET_SUCCESS_RENEWβ same asSSL_TICKET_SUCCESS, but a new ticket should be sent to the client. π
the return value can be any of these values:
SSL_TICKET_RETURN_ABORTβ the handshake should be aborted, either because of an error or because of some policy. > heads up bestie: in TLSv1.3 a client may send more than one ticket in a single handshake. so just because one ticket is unacceptable does not mean all of them are. for this reason this option should be used with caution. β οΈSSL_TICKET_RETURN_IGNOREβ do not use a ticket (if one was available). do not send a renewed ticket to the client. πSSL_TICKET_RETURN_IGNORE_RENEWβ do not use a ticket (if one was available). send a renewed ticket to the client. π ββοΈβ¨- if the callback does not wish to change the default ticket behaviour, then it should return this value if
statusisSSL_TICKET_EMPTYorSSL_TICKET_NO_DECRYPT.
- if the callback does not wish to change the default ticket behaviour, then it should return this value if
SSL_TICKET_RETURN_USEβ use the ticket. do not send a renewed ticket to the client. it is an error for the callback to return this value ifstatushas a value other thanSSL_TICKET_SUCCESSorSSL_TICKET_SUCCESS_RENEW. β- if the callback does not wish to change the default ticket behaviour, then it should return this value if
statusisSSL_TICKET_SUCCESS.
- if the callback does not wish to change the default ticket behaviour, then it should return this value if
SSL_TICKET_RETURN_USE_RENEWβ use the ticket. send a renewed ticket to the client. it is an error for the callback to return this value ifstatushas a value other thanSSL_TICKET_SUCCESSorSSL_TICKET_SUCCESS_RENEW. β π- if the callback does not wish to change the default ticket behaviour, then it should return this value if
statusisSSL_TICKET_SUCCESS_RENEW.
- if the callback does not wish to change the default ticket behaviour, then it should return this value if
if status has the value SSL_TICKET_EMPTY or SSL_TICKET_NO_DECRYPT, then no session data will be available and the callback must not use the ss argument. if status has the value SSL_TICKET_SUCCESS or SSL_TICKET_SUCCESS_RENEW, then the application can call SSL_SESSION_get0_ticket_appdata() using the session provided in the ss argument to retrieve the application data. π
when the gen_cb callback is invoked, the SSL_get_session() function can be used to retrieve the SSL_SESSION for SSL_SESSION_set1_ticket_appdata(). π
by default, in TLSv1.2 and below, a new session ticket is not issued on a successful resumption, and therefore gen_cb will not be called. in TLSv1.3 the default behaviour is to always issue a new ticket on resumption. in both cases this behaviour can be changed if a ticket key callback is in use β see SSL_CTX_set_tlsext_ticket_key_cb(3). π
π RETURN VALUES π
the SSL_CTX_set_session_ticket_cb(), SSL_SESSION_set1_ticket_appdata() and SSL_SESSION_get0_ticket_appdata() functions return 1 on success and 0 on failure. simple as that.
the gen_cb callback must return 1 to continue the connection. a return of 0 will terminate the connection with an INTERNAL_ERROR alert. π±
the dec_cb callback must return a value as described in "NOTES" above. no improvising.
π SEE ALSO π
π°οΈ HISTORY π°οΈ
the SSL_CTX_set_session_ticket_cb(), SSL_SESSION_set1_ticket_appdata() and SSL_SESSION_get_ticket_appdata() functions were added in OpenSSL 1.1.1. so they've been around a minute. β
π COPYRIGHT π
Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page bestie, no cap π«Ά this was SSL_CTX_SET_...ION_TICKET_CB(3ossl) from OpenSSL 3.5.9, dated 2026-09-2, and it literally ate. go forth and ticket responsibly πβ¨π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms