1.\" $OpenBSD: SSL_CTX_add_session.3,v 1.5 2018/03/27 17:35:50 schwarze Exp $ 2.\" OpenSSL SSL_CTX_add_session.pod 1722496f Jun 8 15:18:38 2017 -0400 3.\" 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org> and 5.\" Geoff Thorpe <geoff@openssl.org>. 6.\" Copyright (c) 2001, 2002, 2014 The OpenSSL Project. All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in 17.\" the documentation and/or other materials provided with the 18.\" distribution. 19.\" 20.\" 3. All advertising materials mentioning features or use of this 21.\" software must display the following acknowledgment: 22.\" "This product includes software developed by the OpenSSL Project 23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 24.\" 25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26.\" endorse or promote products derived from this software without 27.\" prior written permission. For written permission, please contact 28.\" openssl-core@openssl.org. 29.\" 30.\" 5. Products derived from this software may not be called "OpenSSL" 31.\" nor may "OpenSSL" appear in their names without prior written 32.\" permission of the OpenSSL Project. 33.\" 34.\" 6. Redistributions of any form whatsoever must retain the following 35.\" acknowledgment: 36.\" "This product includes software developed by the OpenSSL Project 37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 38.\" 39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" 52.Dd $Mdocdate: March 27 2018 $ 53.Dt SSL_CTX_ADD_SESSION 3 54.Os 55.Sh NAME 56.Nm SSL_CTX_add_session , 57.Nm SSL_CTX_remove_session 58.Nd manipulate session cache 59.Sh SYNOPSIS 60.In openssl/ssl.h 61.Ft int 62.Fn SSL_CTX_add_session "SSL_CTX *ctx" "SSL_SESSION *c" 63.Ft int 64.Fn SSL_CTX_remove_session "SSL_CTX *ctx" "SSL_SESSION *c" 65.Sh DESCRIPTION 66.Fn SSL_CTX_add_session 67adds the session 68.Fa c 69to the context 70.Fa ctx . 71The reference count for session 72.Fa c 73is incremented by 1. 74If a session with the same session id already exists, 75the old session is removed by calling 76.Xr SSL_SESSION_free 3 . 77.Pp 78.Fn SSL_CTX_remove_session 79removes the session 80.Fa c 81from the context 82.Fa ctx 83and marks it as non-resumable. 84.Xr SSL_SESSION_free 3 85is called once for 86.Fa c . 87.Pp 88When adding a new session to the internal session cache, it is examined 89whether a session with the same session id already exists. 90In this case it is assumed that both sessions are identical. 91If the same session is stored in a different 92.Vt SSL_SESSION 93object, the old session is removed and replaced by the new session. 94If the session is actually identical (the 95.Vt SSL_SESSION 96object is identical), 97.Fn SSL_CTX_add_session 98is a no-op, and the return value is 0. 99.Pp 100If a server 101.Vt SSL_CTX 102is configured with the 103.Dv SSL_SESS_CACHE_NO_INTERNAL_STORE 104flag then the internal cache will not be populated automatically by new 105sessions negotiated by the SSL/TLS implementation, even though the internal 106cache will be searched automatically for session-resume requests (the 107latter can be suppressed by 108.Dv SSL_SESS_CACHE_NO_INTERNAL_LOOKUP ) . 109So the application can use 110.Fn SSL_CTX_add_session 111directly to have full control over the sessions that can be resumed if desired. 112.Sh RETURN VALUES 113The following values are returned by all functions: 114.Bl -tag -width Ds 115.It 0 116The operation failed. 117In case of the add operation, it was tried to add the same (identical) session 118twice. 119In case of the remove operation, the session was not found in the cache. 120.It 1 121The operation succeeded. 122.El 123.Sh SEE ALSO 124.Xr ssl 3 , 125.Xr SSL_CTX_set_session_cache_mode 3 , 126.Xr SSL_SESSION_free 3 127.Sh HISTORY 128.Fn SSL_CTX_add_session 129and 130.Fn SSL_CTX_remove_session 131first appeared in SSLeay 0.8.0 and have been available since 132.Ox 2.4 . 133