|
| 1 | +=pod |
| 2 | + |
| 3 | +=head1 NAME |
| 4 | + |
| 5 | +SSL_set1_cache_id, |
| 6 | +SSL_get0_cache_id, |
| 7 | +SSL_SESSION_set1_cache_id, |
| 8 | +SSL_SESSION_get0_cache_id, |
| 9 | +SSL_get1_previous_client_session - use application-defined cache identifier for session caching |
| 10 | + |
| 11 | +=head1 SYNOPSIS |
| 12 | + |
| 13 | + #include <openssl/ssl.h> |
| 14 | + |
| 15 | + int SSL_set1_cache_id(SSL *s, const unsigned char *data, size_t len); |
| 16 | + int SSL_get0_cache_id(const SSL *s, const unsigned char **data, size_t *len); |
| 17 | + |
| 18 | + int SSL_SESSION_set1_cache_id(SSL_SESSION *ss, const unsigned char *data, size_t len); |
| 19 | + int SSL_SESSION_get0_cache_id(const SSL_SESSION *ss, const unsigned char **data, size_t *len); |
| 20 | + |
| 21 | + int SSL_get1_previous_client_session(SSL *s, int flags); |
| 22 | + |
| 23 | +=head1 DESCRIPTION |
| 24 | + |
| 25 | +SSL_set1_cache_id() sets the cache identifier specified by B<data> and B<len> |
| 26 | +into B<s>. This cache identifier is application-defined, and can be a domain |
| 27 | +name, IP address, port or other identifier. |
| 28 | + |
| 29 | +SSL_get0_cache_id() returns the cache identifier of B<s> into the B<data> and |
| 30 | +B<len> variables. The cache identifier is application-defined. |
| 31 | + |
| 32 | +SSL_SESSION_set1_cache_id() sets the cache identifier specified by B<data> and B<len> |
| 33 | +into B<ss>. This cache identifier is application-defined. |
| 34 | + |
| 35 | +SSL_SESSION_get0_cache_id() returns the cache identifier of B<ss> into the B<data> and |
| 36 | +B<len> variables. The cache identifier is application-defined. |
| 37 | + |
| 38 | +SSL_get1_previous_client_session() is used to search for and return a |
| 39 | +SSL_SESSION in the session cache. A cache identifier must first be set |
| 40 | +via SSL_set1_cache_id(). |
| 41 | + |
| 42 | +=head1 NOTES |
| 43 | + |
| 44 | +The OpenSSL library can store/retrieve SSL/TLS sessions for later reuse. |
| 45 | +The sessions can be held in memory for each B<ctx>; if more than one |
| 46 | +SSL_CTX object is being maintained, the sessions are unique for each SSL_CTX |
| 47 | +object. The cache mode must be set to SSL_SESS_CACHE_CLIENT via |
| 48 | +L<SSL_CTX_set_session_cache_mode(3)> in order to use application-defined |
| 49 | +cache identifiers. When the cache mode is set to SSL_SESSION_CACHE_SERVER or |
| 50 | +SSL_SESSION_CACHE_BOTH, session IDs are used as the cache identifier. |
| 51 | + |
| 52 | +To reuse a client session, use the SSL_set1_cache_id() function to specify the |
| 53 | +cache identifier of the server that the client is attempting to connect to. Set the |
| 54 | +optional session ID context via L<SSL_CTX_set_session_id_context(3)> or |
| 55 | +L<SSL_set_session_id_context(3)> before calling SSL_get1_previous_client_session(). |
| 56 | + |
| 57 | +After the session has been retrieved, it may be examined to determine whether |
| 58 | +it can (or should) be used. The session must then be applied to the SSL object via the |
| 59 | +L<SSL_set_session(3)> before it can be used during L<SSL_connect(3)>. |
| 60 | + |
| 61 | +The session cache that is searched is specified by the SSL_CTX used in |
| 62 | +L<SSL_new(3)>. The SSL_CTX set via L<SSL_set_SSL_CTX(3)> is not used |
| 63 | +for the session cache. |
| 64 | + |
| 65 | +SSL_SESSION_set1_cache_id() will fail if the B<ss> is already in a cache. This |
| 66 | +function can only be used on non-cached SSL_SESSIONs. |
| 67 | + |
| 68 | +SSL_set1_cache_id() and SSL_SESSION_set1_cache_id() should not be used by servers, |
| 69 | +the functions will fail. |
| 70 | + |
| 71 | +=head1 RETURN VALUES |
| 72 | + |
| 73 | +The SSL_set1_cache_id(), SSL_get0_cache_id(), SSL_SESSION_set1_cache_id() and |
| 74 | +SSL_SESSION_get0_cache_id() functions return 1 on success, 0 on failure. |
| 75 | + |
| 76 | +The SSL_get0_cache_id() function fills in the B<data> and B<len> parameters |
| 77 | +with the data from the B<s>. |
| 78 | + |
| 79 | +The SSL_get_previous_client_session() returns an SSL_SESSION on success, or NULL on |
| 80 | +failure. The error stack should be checked on error. |
| 81 | + |
| 82 | +=head1 SEE ALSO |
| 83 | + |
| 84 | +L<SSL_set_session(3)> |
| 85 | +L<SSL_session_reused(3)> |
| 86 | +L<SSL_CTX_add_session(3)> |
| 87 | +L<SSL_CTX_sess_number(3)> |
| 88 | +L<SSL_CTX_sess_set_cache_size(3)> |
| 89 | +L<SSL_CTX_sess_set_get_cb(3)> |
| 90 | +L<SSL_CTX_set_session_id_context(3)> |
| 91 | +L<SSL_CTX_set_timeout(3)> |
| 92 | +L<SSL_CTX_flush_sessions(3)> |
| 93 | +L<SSL_CTX_set_session_cache_mode(3)>, |
| 94 | +L<SSL_connect(3)>, |
| 95 | +L<SSL_new(3)>, |
| 96 | +L<SSL_set_SSL_CTX(3)>, |
| 97 | + |
| 98 | +=head1 HISTORY |
| 99 | + |
| 100 | +The SSL_set1_cache_id(), |
| 101 | +SSL_get0_cache_id(), |
| 102 | +SSL_SESSION_set1_cache_id(), |
| 103 | +SSL_SESSION_get0_cache_id(), and |
| 104 | +SSL_get1_previous_client_session() functions were added in OpenSSL 3.5. |
| 105 | + |
| 106 | +=head1 COPYRIGHT |
| 107 | + |
| 108 | +Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 109 | + |
| 110 | +Licensed under the OpenSSL license (the "License"). You may not use |
| 111 | +this file except in compliance with the License. You can obtain a copy |
| 112 | +in the file LICENSE in the source distribution or at |
| 113 | +L<https://www.openssl.org/source/license.html>. |
| 114 | + |
| 115 | +=cut |
0 commit comments