5 SSL_CTX_set_async_callback,
6 SSL_CTX_set_async_callback_arg,
7 SSL_set_async_callback,
8 SSL_set_async_callback_arg,
11 - manage asynchronous operations
15 =for openssl multiple includes
17 #include <openssl/ssl.h>
19 typedef int (*SSL_async_callback_fn)(SSL *s, void *arg);
20 int SSL_CTX_set_async_callback(SSL_CTX *ctx, SSL_async_callback_fn callback);
21 int SSL_CTX_set_async_callback_arg(SSL_CTX *ctx, void *arg);
22 int SSL_set_async_callback(SSL *s, SSL_async_callback_fn callback);
23 int SSL_set_async_callback_arg(SSL *s, void *arg);
24 int SSL_get_async_status(SSL *s, int *status);
28 SSL_CTX_set_async_callback() sets an asynchronous callback function. All B<SSL>
29 objects generated based on this B<SSL_CTX> will get this callback. If an engine
30 supports the callback mechanism, it will be automatically called if
31 B<SSL_MODE_ASYNC> has been set and an asynchronous capable engine completes a
32 cryptography operation to notify the application to resume the paused work flow.
34 SSL_CTX_set_async_callback_arg() sets the callback argument.
36 SSL_set_async_callback() allows an application to set a callback in an
37 asynchronous B<SSL> object, so that when an engine completes a cryptography
38 operation, the callback will be called to notify the application to resume the
41 SSL_set_async_callback_arg() sets an argument for the B<SSL> object when the
42 above callback is called.
44 SSL_get_async_status() returns the engine status. This function facilitates the
45 communication from the engine to the application. During an SSL session,
46 cryptographic operations are dispatched to an engine. The engine status is very
47 useful for an application to know if the operation has been successfully
48 dispatched. If the engine does not support this additional callback method,
49 B<ASYNC_STATUS_UNSUPPORTED> will be returned. See ASYNC_WAIT_CTX_set_status()
50 for a description of all of the status values.
52 An example of the above functions would be the following:
58 Application sets the async callback and callback data on an SSL connection
59 by calling SSL_set_async_callback().
63 Application sets B<SSL_MODE_ASYNC> and makes an asynchronous SSL call
67 OpenSSL submits the asynchronous request to the engine. If a retry occurs at
68 this point then the status within the B<ASYNC_WAIT_CTX> would be set and the
69 async callback function would be called (goto Step 7).
73 The OpenSSL engine pauses the current job and returns, so that the
74 application can continue processing other connections.
78 At a future point in time (probably via a polling mechanism or via an
79 interrupt) the engine will become aware that the asynchronous request has
84 The engine will call the application's callback passing the callback data as
89 The callback function should then run. Note: it is a requirement that the
90 callback function is small and non-blocking as it will be run in the context of
91 a polling mechanism or an interrupt.
95 It is the application's responsibility via the callback function to schedule
96 recalling the OpenSSL asynchronous function and to continue processing.
100 The callback function has the option to check the status returned via
101 SSL_get_async_status() to determine whether a retry happened instead of the
102 request being submitted, allowing different processing if required.
108 SSL_CTX_set_async_callback(), SSL_set_async_callback(),
109 SSL_CTX_set_async_callback_arg(), SSL_CTX_set_async_callback_arg() and
110 SSL_get_async_status() return 1 on success or 0 on error.
118 SSL_CTX_set_async_callback(), SSL_CTX_set_async_callback_arg(),
119 SSL_set_async_callback(), SSL_set_async_callback_arg() and
120 SSL_get_async_status() were first added to OpenSSL 3.0.
124 Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
126 Licensed under the OpenSSL license (the "License"). You may not use
127 this file except in compliance with the License. You can obtain a copy
128 in the file LICENSE in the source distribution or at
129 L<https://www.openssl.org/source/license.html>.