Blame doc/man3/SSL_CTX_set_session_ticket_cb.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
SSL_CTX_set_session_ticket_cb,
Packit c4476c
SSL_SESSION_get0_ticket_appdata,
Packit c4476c
SSL_SESSION_set1_ticket_appdata,
Packit c4476c
SSL_CTX_generate_session_ticket_fn,
Packit c4476c
SSL_CTX_decrypt_session_ticket_fn - manage session ticket application data
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/ssl.h>
Packit c4476c
Packit c4476c
 typedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg);
Packit c4476c
 typedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss,
Packit c4476c
                                                                const unsigned char *keyname,
Packit c4476c
                                                                size_t keyname_len,
Packit c4476c
                                                                SSL_TICKET_STATUS status,
Packit c4476c
                                                                void *arg);
Packit c4476c
 int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx,
Packit c4476c
                                   SSL_CTX_generate_session_ticket_fn gen_cb,
Packit c4476c
                                   SSL_CTX_decrypt_session_ticket_fn dec_cb,
Packit c4476c
                                   void *arg);
Packit c4476c
 int SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len);
Packit c4476c
 int SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
SSL_CTX_set_set_session_ticket_cb() sets the application callbacks B<gen_cb>
Packit c4476c
and B<dec_cb> that are used by a server to set and get application data stored
Packit c4476c
with a session, and placed into a session ticket. Either callback function may
Packit c4476c
be set to NULL. The value of B<arg> is passed to the callbacks.
Packit c4476c
Packit c4476c
B<gen_cb> is the application defined callback invoked when a session ticket is
Packit c4476c
about to be created. The application can call SSL_SESSION_set1_ticket_appdata()
Packit c4476c
at this time to add application data to the session ticket. The value of B<arg>
Packit c4476c
is the same as that given to SSL_CTX_set_session_ticket_cb(). The B<gen_cb>
Packit c4476c
callback is defined as type B<SSL_CTX_generate_session_ticket_fn>.
Packit c4476c
Packit c4476c
B<dec_cb> is the application defined callback invoked after session ticket
Packit c4476c
decryption has been attempted and any session ticket application data is
Packit c4476c
available. If ticket decryption was successful then the B<ss> argument contains
Packit c4476c
the session data. The B<keyname> and B<keyname_len> arguments identify the key
Packit c4476c
used to decrypt the session ticket. The B<status> argument is the result of the
Packit c4476c
ticket decryption. See the L<NOTES> section below for further details. The value
Packit c4476c
of B<arg> is the same as that given to SSL_CTX_set_session_ticket_cb(). The
Packit c4476c
B<dec_cb> callback is defined as type B<SSL_CTX_decrypt_session_ticket_fn>.
Packit c4476c
Packit c4476c
SSL_SESSION_set1_ticket_appdata() sets the application data specified by
Packit c4476c
B<data> and B<len> into B<ss> which is then placed into any generated session
Packit c4476c
tickets. It can be called at any time before a session ticket is created to
Packit c4476c
update the data placed into the session ticket. However, given that sessions
Packit c4476c
and tickets are created by the handshake, the B<gen_cb> is provided to notify
Packit c4476c
the application that a session ticket is about to be generated.
Packit c4476c
Packit c4476c
SSL_SESSION_get0_ticket_appdata() assigns B<data> to the session ticket
Packit c4476c
application data and assigns B<len> to the length of the session ticket
Packit c4476c
application data from B<ss>. The application data can be set via
Packit c4476c
SSL_SESSION_set1_ticket_appdata() or by a session ticket. NULL will be assigned
Packit c4476c
to B<data> and 0 will be assigned to B<len> if there is no session ticket
Packit c4476c
application data. SSL_SESSION_get0_ticket_appdata() can be called any time
Packit c4476c
after a session has been created. The B<dec_cb> is provided to notify the
Packit c4476c
application that a session ticket has just been decrypted.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
When the B<dec_cb> callback is invoked, the SSL_SESSION B<ss> has not yet been
Packit c4476c
assigned to the SSL B<s>. The B<status> indicates the result of the ticket
Packit c4476c
decryption. The callback must check the B<status> value before performing any
Packit c4476c
action, as it is called even if ticket decryption fails.
Packit c4476c
Packit c4476c
The B<keyname> and B<keyname_len> arguments to B<dec_cb> may be used to identify
Packit c4476c
the key that was used to encrypt the session ticket.
Packit c4476c
Packit c4476c
The B<status> argument can be any of these values:
Packit c4476c
Packit c4476c
=over 4
Packit c4476c
Packit c4476c
=item SSL_TICKET_EMPTY
Packit c4476c
Packit c4476c
Empty ticket present. No ticket data will be used and a new ticket should be
Packit c4476c
sent to the client. This only occurs in TLSv1.2 or below. In TLSv1.3 it is not
Packit c4476c
valid for a client to send an empty ticket.
Packit c4476c
Packit c4476c
=item SSL_TICKET_NO_DECRYPT
Packit c4476c
Packit c4476c
The ticket couldn't be decrypted. No ticket data will be used and a new ticket
Packit c4476c
should be sent to the client.
Packit c4476c
Packit c4476c
=item SSL_TICKET_SUCCESS
Packit c4476c
Packit c4476c
A ticket was successfully decrypted, any session ticket application data should
Packit c4476c
be available. A new ticket should not be sent to the client.
Packit c4476c
Packit c4476c
=item SSL_TICKET_SUCCESS_RENEW
Packit c4476c
Packit c4476c
Same as B<SSL_TICKET_SUCCESS>, but a new ticket should be sent to the client.
Packit c4476c
Packit c4476c
=back
Packit c4476c
Packit c4476c
The return value can be any of these values:
Packit c4476c
Packit c4476c
=over 4
Packit c4476c
Packit c4476c
=item SSL_TICKET_RETURN_ABORT
Packit c4476c
Packit c4476c
The handshake should be aborted, either because of an error or because of some
Packit c4476c
policy. Note that in TLSv1.3 a client may send more than one ticket in a single
Packit c4476c
handshake. Therefore just because one ticket is unacceptable it does not mean
Packit c4476c
that all of them are. For this reason this option should be used with caution.
Packit c4476c
Packit c4476c
=item SSL_TICKET_RETURN_IGNORE
Packit c4476c
Packit c4476c
Do not use a ticket (if one was available). Do not send a renewed ticket to the
Packit c4476c
client.
Packit c4476c
Packit c4476c
=item SSL_TICKET_RETURN_IGNORE_RENEW
Packit c4476c
Packit c4476c
Do not use a ticket (if one was available). Send a renewed ticket to the client.
Packit c4476c
Packit c4476c
If the callback does not wish to change the default ticket behaviour then it
Packit c4476c
should return this value if B<status> is B<SSL_TICKET_EMPTY> or
Packit c4476c
B<SSL_TICKET_NO_DECRYPT>.
Packit c4476c
Packit c4476c
=item SSL_TICKET_RETURN_USE
Packit c4476c
Packit c4476c
Use the ticket. Do not send a renewed ticket to the client. It is an error for
Packit c4476c
the callback to return this value if B<status> has a value other than
Packit c4476c
B<SSL_TICKET_SUCCESS> or B<SSL_TICKET_SUCCESS_RENEW>.
Packit c4476c
Packit c4476c
If the callback does not wish to change the default ticket behaviour then it
Packit c4476c
should return this value if B<status> is B<SSL_TICKET_SUCCESS>.
Packit c4476c
Packit c4476c
=item SSL_TICKET_RETURN_USE_RENEW
Packit c4476c
Packit c4476c
Use the ticket. Send a renewed ticket to the client. It is an error for the
Packit c4476c
callback to return this value if B<status> has a value other than
Packit c4476c
B<SSL_TICKET_SUCCESS> or B<SSL_TICKET_SUCCESS_RENEW>.
Packit c4476c
Packit c4476c
If the callback does not wish to change the default ticket behaviour then it
Packit c4476c
should return this value if B<status> is B<SSL_TICKET_SUCCESS_RENEW>.
Packit c4476c
Packit c4476c
=back
Packit c4476c
Packit c4476c
If B<status> has the value B<SSL_TICKET_EMPTY> or B<SSL_TICKET_NO_DECRYPT> then
Packit c4476c
no session data will be available and the callback must not use the B<ss>
Packit c4476c
argument. If B<status> has the value B<SSL_TICKET_SUCCESS> or
Packit c4476c
B<SSL_TICKET_SUCCESS_RENEW> then the application can call
Packit c4476c
SSL_SESSION_get0_ticket_appdata() using the session provided in the B<ss>
Packit c4476c
argument to retrieve the application data.
Packit c4476c
Packit c4476c
When the B<gen_cb> callback is invoked, the SSL_get_session() function can be
Packit c4476c
used to retrieve the SSL_SESSION for SSL_SESSION_set1_ticket_appdata().
Packit c4476c
Packit c4476c
By default, in TLSv1.2 and below, a new session ticket is not issued on a
Packit c4476c
successful resumption and therefore B<gen_cb> will not be called. In TLSv1.3 the
Packit c4476c
default behaviour is to always issue a new ticket on resumption. In both cases
Packit c4476c
this behaviour can be changed if a ticket key callback is in use (see
Packit c4476c
L<SSL_CTX_set_tlsext_ticket_key_cb(3)>).
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
The SSL_CTX_set_session_ticket_cb(), SSL_SESSION_set1_ticket_appdata() and
Packit c4476c
SSL_SESSION_get0_ticket_appdata() functions return 1 on success and 0 on
Packit c4476c
failure.
Packit c4476c
Packit c4476c
The B<gen_cb> callback must return 1 to continue the connection. A return of 0
Packit c4476c
will terminate the connection with an INTERNAL_ERROR alert.
Packit c4476c
Packit c4476c
The B<dec_cb> callback must return a value as described in L<NOTES> above.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<ssl(7)>,
Packit c4476c
L<SSL_get_session(3)>
Packit c4476c
Packit c4476c
=head1 HISTORY
Packit c4476c
Packit c4476c
The SSL_CTX_set_session_ticket_cb(), SSSL_SESSION_set1_ticket_appdata()
Packit c4476c
and SSL_SESSION_get_ticket_appdata() functions were added in OpenSSL 1.1.1.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut