1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimSSL_set_session - set a TLS/SSL session to be used during TLS/SSL connect 6e71b7053SJung-uk Kim 7e71b7053SJung-uk Kim=head1 SYNOPSIS 8e71b7053SJung-uk Kim 9e71b7053SJung-uk Kim #include <openssl/ssl.h> 10e71b7053SJung-uk Kim 11e71b7053SJung-uk Kim int SSL_set_session(SSL *ssl, SSL_SESSION *session); 12e71b7053SJung-uk Kim 13e71b7053SJung-uk Kim=head1 DESCRIPTION 14e71b7053SJung-uk Kim 15e71b7053SJung-uk KimSSL_set_session() sets B<session> to be used when the TLS/SSL connection 16e71b7053SJung-uk Kimis to be established. SSL_set_session() is only useful for TLS/SSL clients. 17e71b7053SJung-uk KimWhen the session is set, the reference count of B<session> is incremented 18e71b7053SJung-uk Kimby 1. If the session is not reused, the reference count is decremented 19e71b7053SJung-uk Kimagain during SSL_connect(). Whether the session was reused can be queried 20e71b7053SJung-uk Kimwith the L<SSL_session_reused(3)> call. 21e71b7053SJung-uk Kim 22e71b7053SJung-uk KimIf there is already a session set inside B<ssl> (because it was set with 23e71b7053SJung-uk KimSSL_set_session() before or because the same B<ssl> was already used for 24*b077aed3SPierre Proncherya connection), SSL_SESSION_free() will be called for that session. 25*b077aed3SPierre ProncheryThis is also the case when B<session> is a NULL pointer. If that old 26e71b7053SJung-uk Kimsession is still B<open>, it is considered bad and will be removed from the 27e71b7053SJung-uk Kimsession cache (if used). A session is considered open, if L<SSL_shutdown(3)> was 28e71b7053SJung-uk Kimnot called for the connection (or at least L<SSL_set_shutdown(3)> was used to 29e71b7053SJung-uk Kimset the SSL_SENT_SHUTDOWN state). 30e71b7053SJung-uk Kim 31e71b7053SJung-uk Kim=head1 NOTES 32e71b7053SJung-uk Kim 33e71b7053SJung-uk KimSSL_SESSION objects keep internal link information about the session cache 34e71b7053SJung-uk Kimlist, when being inserted into one SSL_CTX object's session cache. 35e71b7053SJung-uk KimOne SSL_SESSION object, regardless of its reference count, must therefore 36e71b7053SJung-uk Kimonly be used with one SSL_CTX object (and the SSL objects created 37e71b7053SJung-uk Kimfrom this SSL_CTX object). 38e71b7053SJung-uk Kim 39e71b7053SJung-uk Kim=head1 RETURN VALUES 40e71b7053SJung-uk Kim 41e71b7053SJung-uk KimThe following return values can occur: 42e71b7053SJung-uk Kim 43e71b7053SJung-uk Kim=over 4 44e71b7053SJung-uk Kim 45e71b7053SJung-uk Kim=item Z<>0 46e71b7053SJung-uk Kim 47e71b7053SJung-uk KimThe operation failed; check the error stack to find out the reason. 48e71b7053SJung-uk Kim 49e71b7053SJung-uk Kim=item Z<>1 50e71b7053SJung-uk Kim 51e71b7053SJung-uk KimThe operation succeeded. 52e71b7053SJung-uk Kim 53e71b7053SJung-uk Kim=back 54e71b7053SJung-uk Kim 55e71b7053SJung-uk Kim=head1 SEE ALSO 56e71b7053SJung-uk Kim 57e71b7053SJung-uk KimL<ssl(7)>, L<SSL_SESSION_free(3)>, 58e71b7053SJung-uk KimL<SSL_get_session(3)>, 59e71b7053SJung-uk KimL<SSL_session_reused(3)>, 60e71b7053SJung-uk KimL<SSL_CTX_set_session_cache_mode(3)> 61e71b7053SJung-uk Kim 62e71b7053SJung-uk Kim=head1 COPYRIGHT 63e71b7053SJung-uk Kim 64*b077aed3SPierre ProncheryCopyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved. 65e71b7053SJung-uk Kim 66*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 67e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 68e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 69e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 70e71b7053SJung-uk Kim 71e71b7053SJung-uk Kim=cut 72