MySQL 8.0 C API Developer Guide
void * mysql_get_ssl_session_data(MYSQL *, unsigned int n_ticket, unsigned int *out_len)
mysql_get_ssl_session_data()
permits SSL session reuse by extracting a ticket from an
established session and submitting that ticket when
connecting, provided the server still has the session in its
runtime cache. This function returns a session data string and
provides the length of the string in
out_len
(if non-NULL). Otherwise, it
returns nullptr
to indicate the expected
session data is not possible or the connection is not in the
right state. To prevent leaks, you must release the session
data handle by calling
mysql_free_ssl_session_data()
when your application is finished with the pointer.
The format of the data is PEM serialization of the session. A session can be reused only if it was fetched from a prior session to the same mysqld server on the same port. In addition, the SSL version of the new session must match the SSL version of the original session.
n_ticket
specifies which ticket or tickets
to returned. For TLS 1.3, the server generates two session
tickets by default for new sessions and one when a session is
reused. For TLS 1.2, the server generates one session ticket
by default. This should be considered when deciding on the
size of the SSL session cache on the server.
Currently, only the last transmitted session is returned.
Specifically, anything other than 0 for
n_ticket
causes an error. OpenSSL version
1.0.2 imposes this limitation.
Avoid reusing SSL sessions more than one time.