1*689a5e03Sjmc.\" $OpenBSD: SSL_clear.3,v 1.5 2021/06/11 19:41:39 jmc Exp $ 24114d59dSschwarze.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 3f1a3c524Sschwarze.\" 44114d59dSschwarze.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>. 54114d59dSschwarze.\" Copyright (c) 2000, 2001, 2002, 2011, 2015 The OpenSSL Project. 64114d59dSschwarze.\" All rights reserved. 7f1a3c524Sschwarze.\" 84114d59dSschwarze.\" Redistribution and use in source and binary forms, with or without 94114d59dSschwarze.\" modification, are permitted provided that the following conditions 104114d59dSschwarze.\" are met: 114114d59dSschwarze.\" 124114d59dSschwarze.\" 1. Redistributions of source code must retain the above copyright 134114d59dSschwarze.\" notice, this list of conditions and the following disclaimer. 144114d59dSschwarze.\" 154114d59dSschwarze.\" 2. Redistributions in binary form must reproduce the above copyright 164114d59dSschwarze.\" notice, this list of conditions and the following disclaimer in 174114d59dSschwarze.\" the documentation and/or other materials provided with the 184114d59dSschwarze.\" distribution. 194114d59dSschwarze.\" 204114d59dSschwarze.\" 3. All advertising materials mentioning features or use of this 214114d59dSschwarze.\" software must display the following acknowledgment: 224114d59dSschwarze.\" "This product includes software developed by the OpenSSL Project 234114d59dSschwarze.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 244114d59dSschwarze.\" 254114d59dSschwarze.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 264114d59dSschwarze.\" endorse or promote products derived from this software without 274114d59dSschwarze.\" prior written permission. For written permission, please contact 284114d59dSschwarze.\" openssl-core@openssl.org. 294114d59dSschwarze.\" 304114d59dSschwarze.\" 5. Products derived from this software may not be called "OpenSSL" 314114d59dSschwarze.\" nor may "OpenSSL" appear in their names without prior written 324114d59dSschwarze.\" permission of the OpenSSL Project. 334114d59dSschwarze.\" 344114d59dSschwarze.\" 6. Redistributions of any form whatsoever must retain the following 354114d59dSschwarze.\" acknowledgment: 364114d59dSschwarze.\" "This product includes software developed by the OpenSSL Project 374114d59dSschwarze.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 384114d59dSschwarze.\" 394114d59dSschwarze.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 404114d59dSschwarze.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 414114d59dSschwarze.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 424114d59dSschwarze.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 434114d59dSschwarze.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 444114d59dSschwarze.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 454114d59dSschwarze.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 464114d59dSschwarze.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 474114d59dSschwarze.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 484114d59dSschwarze.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 494114d59dSschwarze.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 504114d59dSschwarze.\" OF THE POSSIBILITY OF SUCH DAMAGE. 514114d59dSschwarze.\" 52*689a5e03Sjmc.Dd $Mdocdate: June 11 2021 $ 53f1a3c524Sschwarze.Dt SSL_CLEAR 3 54f1a3c524Sschwarze.Os 55f1a3c524Sschwarze.Sh NAME 56f1a3c524Sschwarze.Nm SSL_clear 57f1a3c524Sschwarze.Nd reset SSL object to allow another connection 58f1a3c524Sschwarze.Sh SYNOPSIS 59f1a3c524Sschwarze.In openssl/ssl.h 60f1a3c524Sschwarze.Ft int 61f1a3c524Sschwarze.Fn SSL_clear "SSL *ssl" 62f1a3c524Sschwarze.Sh DESCRIPTION 63f1a3c524SschwarzeReset 64f1a3c524Sschwarze.Fa ssl 65f1a3c524Sschwarzeto allow another connection. 66f1a3c524SschwarzeAll settings (method, ciphers, BIOs) are kept. 674114d59dSschwarze.Pp 68f1a3c524Sschwarze.Fn SSL_clear 69f1a3c524Sschwarzeis used to prepare an 70f1a3c524Sschwarze.Vt SSL 71f1a3c524Sschwarzeobject for a new connection. 72f1a3c524SschwarzeWhile all settings are kept, 73f1a3c524Sschwarzea side effect is the handling of the current SSL session. 74f1a3c524SschwarzeIf a session is still 75f1a3c524Sschwarze.Em open , 76f1a3c524Sschwarzeit is considered bad and will be removed from the session cache, 77f1a3c524Sschwarzeas required by RFC 2246. 78f1a3c524SschwarzeA session is considered open if 79f1a3c524Sschwarze.Xr SSL_shutdown 3 80f1a3c524Sschwarzewas not called for the connection or at least 81f1a3c524Sschwarze.Xr SSL_set_shutdown 3 82f1a3c524Sschwarzewas used to 83f1a3c524Sschwarzeset the 84f1a3c524Sschwarze.Dv SSL_SENT_SHUTDOWN 85f1a3c524Sschwarzestate. 86f1a3c524Sschwarze.Pp 87f1a3c524SschwarzeIf a session was closed cleanly, 88f1a3c524Sschwarzethe session object will be kept and all settings corresponding. 89f1a3c524SschwarzeThis explicitly means that for example the special method used during the 90f1a3c524Sschwarzesession will be kept for the next handshake. 91f1a3c524SschwarzeSo if the session was a TLSv1 session, a 92f1a3c524Sschwarze.Vt SSL 93f1a3c524Sschwarzeclient object will use a TLSv1 client method for the next handshake and a 94f1a3c524Sschwarze.Vt SSL 95f1a3c524Sschwarzeserver object will use a TLSv1 server method, even if 964114d59dSschwarze.Fn TLS_*_method Ns s 97f1a3c524Sschwarzewere chosen on startup. 98f1a3c524SschwarzeThis might lead to connection failures (see 99f1a3c524Sschwarze.Xr SSL_new 3 ) 100f1a3c524Sschwarzefor a description of the method's properties. 101f1a3c524Sschwarze.Sh RETURN VALUES 102f1a3c524SschwarzeThe following return values can occur: 103f1a3c524Sschwarze.Bl -tag -width Ds 104f1a3c524Sschwarze.It 0 105f1a3c524SschwarzeThe 106f1a3c524Sschwarze.Fn SSL_clear 107f1a3c524Sschwarzeoperation could not be performed. 108f1a3c524SschwarzeCheck the error stack to find out the reason. 109f1a3c524Sschwarze.It 1 110f1a3c524SschwarzeThe 111f1a3c524Sschwarze.Fn SSL_clear 112f1a3c524Sschwarzeoperation was successful. 113f1a3c524Sschwarze.El 114f1a3c524Sschwarze.Sh SEE ALSO 115f1a3c524Sschwarze.Xr ssl 3 , 116f1a3c524Sschwarze.Xr SSL_CTX_set_client_cert_cb 3 , 117f1a3c524Sschwarze.Xr SSL_CTX_set_options 3 , 118f1a3c524Sschwarze.Xr SSL_free 3 , 119f1a3c524Sschwarze.Xr SSL_new 3 , 120f1a3c524Sschwarze.Xr SSL_set_shutdown 3 , 121f1a3c524Sschwarze.Xr SSL_shutdown 3 1228fba1ec8Sschwarze.Sh HISTORY 1238fba1ec8Sschwarze.Fn SSL_clear 12410e00d17Sschwarzefirst appeared in SSLeay 0.4.5b and has been available since 1258fba1ec8Sschwarze.Ox 2.4 . 1264114d59dSschwarze.Sh CAVEATS 1274114d59dSschwarze.Fn SSL_clear 1284114d59dSschwarzeresets the 1294114d59dSschwarze.Vt SSL 1304114d59dSschwarzeobject to allow for another connection. 1314114d59dSschwarzeThe reset operation however keeps several settings of the last sessions 1324114d59dSschwarze(some of these settings were made automatically during the last handshake). 1334114d59dSschwarzeIt only makes sense for a new connection with the exact same peer that shares 1344114d59dSschwarzethese settings, 1354114d59dSschwarzeand may fail if that peer changes its settings between connections. 1364114d59dSschwarzeUse the sequence 1374114d59dSschwarze.Xr SSL_get_session 3 ; 1384114d59dSschwarze.Xr SSL_new 3 ; 1394114d59dSschwarze.Xr SSL_set_session 3 ; 1404114d59dSschwarze.Xr SSL_free 3 1414114d59dSschwarzeinstead to avoid such failures (or simply 1424114d59dSschwarze.Xr SSL_free 3 ; 1434114d59dSschwarze.Xr SSL_new 3 1444114d59dSschwarzeif session reuse is not desired). 145