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