SSL_SET_ASYNC_CALLBACK(3ossl)
π SSL_SET_ASYNC_CALLBACK π
okay so bestie, this is the 3ossl manual page for SSL_SET_ASYNC_CALLBACK, and it's all about managing asynchronous operations β¨ Like, the functions in here are SSL_CTX_set_async_callback, SSL_CTX_set_async_callback_arg, SSL_set_async_callback, SSL_set_async_callback_arg, SSL_get_async_status, and the callback type SSL_async_callback_fn. Grab a snack, we're going in π
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
typedef int (*SSL_async_callback_fn)(SSL *s, void *arg);
int SSL_CTX_set_async_callback(SSL_CTX *ctx, SSL_async_callback_fn callback);
int SSL_CTX_set_async_callback_arg(SSL_CTX *ctx, void *arg);
int SSL_set_async_callback(SSL *s, SSL_async_callback_fn callback);
int SSL_set_async_callback_arg(SSL *s, void *arg);
int SSL_get_async_status(SSL *s, int *status);
π¦ DESCRIPTION π¦
setting up the callback, ctx edition
SSL_CTX_set_async_callback() sets an asynchronous callback function. Every single SSL object that gets generated off this SSL_CTX will inherit that callback β no cap. And here's the vibe: if an engine supports the callback mechanism, it gets called automatically if SSL_MODE_ASYNC has been set and an async-capable engine finishes a cryptography operation. Its whole job is to ping the application like "hey bestie, resume the paused work flow" π
and the arg that rides along
SSL_CTX_set_async_callback_arg() sets the callback argument. That's it, that's the whole function, it's giving very "supporting character but essential" π
now for the per-SSL versions
SSL_set_async_callback() lets an application set a callback on one specific asynchronous SSL object, so that when an engine completes a cryptography operation, the callback fires and tells the application to resume the paused work flow β¨
SSL_set_async_callback_arg() sets an argument for the SSL object that gets handed over when the above callback is called.
the status check, iykyk
SSL_get_async_status() returns the engine status. This function is literally the communication line from the engine to the application π«Ά During an SSL session, cryptographic operations get dispatched to an engine, and knowing that engine status is super useful β it's how an application finds out whether the operation was successfully dispatched or not. If the engine doesn't support this additional callback method, ASYNC_STATUS_UNSUPPORTED gets returned. And if you want the full rundown of every status value, go look at ASYNC_WAIT_CTX_set_status() π
the example flow, step by step
An example of the above functions would be the following:
- Application sets the async callback and callback data on an SSL connection by calling
SSL_set_async_callback(). - Application sets
SSL_MODE_ASYNCand makes an asynchronous SSL call - OpenSSL submits the asynchronous request to the engine. If a retry occurs at this point then the status within the
ASYNC_WAIT_CTXwould be set and the async callback function would be called (goto Step 7). - The OpenSSL engine pauses the current job and returns, so that the application can continue processing other connections.
- At a future point in time (probably via a polling mechanism or via an interrupt) the engine will become aware that the asynchronous request has finished processing.
- The engine will call the application's callback passing the callback data as a parameter.
- The callback function should then run. Note: it is a requirement that the callback function is small and nonblocking as it will be run in the context of a polling mechanism or an interrupt.
- It is the application's responsibility via the callback function to schedule recalling the OpenSSL asynchronous function and to continue processing.
- The callback function has the option to check the status returned via
SSL_get_async_status()to determine whether a retry happened instead of the request being submitted, allowing different processing if required.
π¨ okay real talk for a sec β step 7 is not a suggestion. That callback must be small and nonblocking, because it's running inside a polling mechanism or an interrupt. No long tasks, no blocking calls, periodt π
π RETURN VALUES π
SSL_CTX_set_async_callback(), SSL_set_async_callback(), SSL_CTX_set_async_callback_arg(), SSL_set_async_callback_arg() and SSL_get_async_status() return 1 on success or 0 on error. Slay β
/ not slay β, very binary of them.
π SEE ALSO π
πΈ HISTORY πΈ
SSL_CTX_set_async_callback(), SSL_CTX_set_async_callback_arg(), SSL_set_async_callback(), SSL_set_async_callback_arg() and SSL_get_async_status() were first added to OpenSSL 3.0. So they're giving fresh-faced 3.0 energy, not legacy icon π§
π COPYRIGHT π
Copyright 2019-2020 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 SSL_SET_ASYNC_CALLBACK(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β go forth and async responsibly, mwah πβ¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms