SSL_HANDLE_EVENTS(3SSL)
π SSL_HANDLE_EVENTS(3SSL) π
okay bestie, gather round, because we're learning about SSL_handle_events β it lives in the 3SSL section of the OpenSSL manual, and honestly? it's giving main character energy for nonblocking apps. let's go π¦
β¨ NAME β¨
SSL_handle_events β advance the async state machine and do network I/O. yes literally, it's the multitasker. π
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
int SSL_handle_events(SSL *ssl);
β¨ DESCRIPTION β¨
so SSL_handle_events() does all the internal processing that's due on an SSL object right now. and the exact stuff it does? honestly depends on what protocol your SSL object is vibing with. like, it might handle timeout events that have become due, or it might β to the extent that's currently possible β try to do network I/O on one of the BIOs underlying the SSL object. π«Ά
the main character use case here is this: if your app uses OpenSSL in nonblocking mode, SSL_handle_events() gives OpenSSL a chance to handle timer events, or to respond when there's new data to read from an underlying BIO, or to jump on the opportunity to write pending data to an underlying BIO. it's the "hey bestie, anything you need rn?" function.
now, SSL_handle_events() can only be used with these types of SSL object:
πΈ DTLS SSL objects
using SSL_handle_events() on an SSL object that's being used with a DTLS method means timeout events get handled properly, the way they should. this is equivalent to a call to DTLSv1_handle_timeout(3). and because SSL_handle_events() handles a superset of the use cases of DTLSv1_handle_timeout(3), it's the one you should prefer for new applications that don't need support for OpenSSL 3.1 or older. glow up, periodt. β¨
when you're using DTLS, your application must call SSL_handle_events() as indicated by calls to SSL_get_event_timeout(3). like, event handling is not performed automatically by calls to other SSL functions such as SSL_read(3) or SSL_write(3). and heads up β this is different to QUIC, which also performs event handling implicitly. see below, iykyk. π
π QUIC connection SSL objects
using SSL_handle_events() on an SSL object that represents a QUIC connection means timeout events get handled properly, incoming network data gets processed, and queued outgoing network data gets written β but only if the underlying BIO has the capacity to accept it. π
so normally, when an app uses an SSL object in blocking mode, it doesn't need to call SSL_handle_events() at all, because OpenSSL does ticking internally on an automatic basis. (yes, auto-ticking, iconic.) but if your app uses a QUIC connection in nonblocking mode, it must β at a minimum β make sure SSL_handle_events() gets called periodically so timeout events actually get handled. and how do you know when you next need to call it for that purpose (if at all)? call SSL_get_event_timeout(3). it'll tell you. π
calling SSL_handle_events() on a QUIC connection SSL object that's being used in blocking mode is not necessary β unless no I/O calls (like SSL_read(3) or SSL_write(3)) will be made to the object for a substantial period of time. so long as at least one call to the SSL object is blocking, no such call is needed. that said, SSL_handle_events() may optionally be used on a QUIC connection object if you want to. no pressure, your choice. πβοΈ
and with the thread-assisted mode of operation OSSL_QUIC_client_thread_method(3), it is unnecessary to call SSL_handle_events(), because the assist thread handles the QUIC connection events for you. teamwork, slay. π§
π the no-op zone
calling SSL_handle_events() on any other kind of SSL object is a no-op. and that's considered a success case. so if nothing happens, you didn't do it wrong, bestie. π
important note:SSL_handle_events()supersedes the olderDTLSv1_handle_timeout(3)function for all use cases. all of them. every single one. π
β¨ RETURN VALUES β¨
returns 1 on success and 0 on failure. that's it, that's the whole vibe. β
β¨ SEE ALSO β¨
β¨ HISTORY β¨
the SSL_handle_events() function was added in OpenSSL 3.2. a relatively fresh icon. π
β¨ COPYRIGHT β¨
Copyright 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>.
okay that's the whole page, bestie!! π this was version 4.0.3, dated 2026-09-29, and it's the SSL_HANDLE_EVENTS(3SSL) manual page. go forth and handle your events, you absolute legend. πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms