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