SSL_CLEAR(3ossl)
π SSL_CLEAR β reset SSL object to allow another connection
okay so you found the SSL_CLEAR(3ossl) page, bestie β welcome, this is the OpenSSL corner of the manual and we're gonna get you fluent. π¦
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
int SSL_clear(SSL *ssl);
πΈ DESCRIPTION πΈ
So SSL_clear() resets ssl so you can do another connection with it. And the icon behavior? All settings are kept β the method, the ciphers, the BIOs. Nothing gets thrown out. Slay. π
π NOTES π
SSL_clear is literally the "prep this SSL object for a new connection" function. But here's the plot twist, and it's giving main-character side effect: it also handles the current SSL session.
- If a session is still open, it's considered bad and gets removed from the session cache β that's not a vibe choice, that's required by RFC2246.
- A session counts as open if
SSL_shutdown(3)was not called for the connection, or if at leastSSL_set_shutdown(3)was used to set theSSL_SENT_SHUTDOWNstate.
Now if the session was closed cleanly? Then the session object is kept, along with all the corresponding settings. And bestie, that explicitly means stuff like: the special method used during that session stays for the next handshake. π So if it was a TLSv1 session, an SSL client object will use a TLSv1 client method for the next handshake, and an SSL server object will use a TLSv1 server method β even if TLS_*_methods were chosen on startup. Yeah. That might lead to connection failures (peep SSL_new(3) for a description of the method's properties).
Also important π«Ά: this function is not supported on QUIC SSL objects and returns failure if you call it on one.
π₯ WARNINGS π₯
SSL_clear() resets the SSL object to allow for another connection, but the reset operation keeps several settings of the last session (some of these settings were made automatically during the last handshake). It only makes sense for a new connection with the exact same peer that shares these settings, and it may fail if that peer changes its settings between connections.
So instead, use this sequence to dodge those failures:
SSL_get_session(3);
SSL_new(3);
SSL_set_session(3);
SSL_free(3);
Or honestly, if you don't even want session reuse: just SSL_free(3); SSL_new(3). Simple. Clean. Periodt. β¨
β RETURN VALUES β
The following return values can occur:
0β theSSL_clear()operation could not be performed. Check the error stack to find out the reason. π1β theSSL_clear()operation was successful. π
π SEE ALSO
SSL_new(3), SSL_free(3), SSL_shutdown(3), SSL_set_shutdown(3), SSL_CTX_set_options(3), ssl(7), SSL_CTX_set_client_cert_cb(3)
π COPYRIGHT π
Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, bestie π§ β this was OpenSSL 3.5.6, dated 2026-04-07, and yes it's SSL_CLEAR(3ossl) all the way down. now go forth and clear those SSL objects responsibly π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms