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