mbedtls_ssl_session_save() function
Save session structure as serialized data in a buffer. On client, this can be used for saving session data, potentially in non-volatile storage, for resuming later. On server, this can be used for alternative implementations of session cache or session tickets. \see mbedtls_ssl_session_load()
Arguments
session
The session structure to be saved.
buf
The buffer to write the serialized data to. It must be a writeable buffer of at least \p buf_len bytes, or may be \c NULL if \p buf_len is \c 0.
buf_len
The number of bytes available for writing in \p buf.
olen
The size in bytes of the data that has been or would have been written. It must point to a valid \c size_t.
Return value
\c 0 if successful. #MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL if \p buf is too small. #MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE if the MBEDTLS_SSL_SESSION_TICKETS configuration option is disabled and the session is a TLS 1.3 session.
Notes
\p olen is updated to the correct value regardless of whether \p buf_len was large enough. This makes it possible to determine the necessary size by calling this function with \p buf set to \c NULL and \p buf_len to \c 0. For TLS 1.3 sessions, this feature is supported only if the MBEDTLS_SSL_SESSION_TICKETS configuration option is enabled, as in TLS 1.3 session resumption is possible only with tickets.
mbedtls_ssl_session_save() is called by 2 functions and calls 1 function:
![]()
mbedtls_ssl_session_save()
mbedtls_ssl_session_save():
![]()
mbedtls_ssl_session_save()