SSL_set_async_callback.pod 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_async_callback,
  4. SSL_CTX_set_async_callback_arg,
  5. SSL_set_async_callback,
  6. SSL_set_async_callback_arg,
  7. SSL_get_async_status,
  8. SSL_async_callback_fn
  9. - manage asynchronous operations
  10. =head1 SYNOPSIS
  11. =for comment multiple includes
  12. #include <openssl/ssl.h>
  13. typedef int (*SSL_async_callback_fn)(SSL *s, void *arg);
  14. int SSL_CTX_set_async_callback(SSL_CTX *ctx, SSL_async_callback_fn callback);
  15. int SSL_CTX_set_async_callback_arg(SSL_CTX *ctx, void *arg);
  16. int SSL_set_async_callback(SSL *s, SSL_async_callback_fn callback);
  17. int SSL_set_async_callback_arg(SSL *s, void *arg);
  18. int SSL_get_async_status(SSL *s, int *status);
  19. =head1 DESCRIPTION
  20. SSL_CTX_set_async_callback() sets an asynchronous callback function. All SSL
  21. objects generated based on this SSL_CTX will get this callback. If an engine
  22. supports the callback mechanism, it will be automatically called if
  23. SSL_MODE_ASYNC has been set and an asynchronous capable engine completes a
  24. cryptography operation to notify the application to resume the paused work flow.
  25. SSL_CTX_set_async_callback_arg() sets the callback argument.
  26. SSL_set_async_callback() allows an application to set a callback in an
  27. asynchronous SSL object, so that when an engine completes a cryptography
  28. operation, the callback will be called to notify the application to resume the
  29. paused work flow.
  30. SSL_set_async_callback_arg() sets an argument for the SSL object when the above
  31. callback is called.
  32. SSL_get_async_status() returns the engine status. This function facilitates the
  33. communication from the engine to the application. During an SSL session,
  34. cryptographic operations are dispatched to an engine. The engine status is very
  35. useful for an application to know if the operation has been successfully
  36. dispatched. If the engine does not support this additional callback method,
  37. "ASYNC_STATUS_UNSUPPORTED" will be returned. See ASYNC_WAIT_CTX_set_status() for
  38. a description of all of the status values.
  39. An example of the above functions would be the following.
  40. 1. Application sets the async callback and callback data on an SSL connection
  41. by calling SSL_set_async_callback().
  42. 2. Application sets SSL_MODE_ASYNC and makes an asynchronous SSL call
  43. 3. OpenSSL submits the asynchronous request to the engine. If a retry occurs at
  44. this point then the status within the ASYNC_WAIT_CTX would be set and the async
  45. callback function would be called (goto Step 7).
  46. 4. The OpenSSL engine pauses the current job and returns, so that the
  47. application can continue processing other connections.
  48. 5. At a future point in time (probably via a polling mechanism or via an
  49. interrupt) the engine will become aware that the asynchronous request has
  50. finished processing.
  51. 6. The engine will call the application's callback passing the callback data as
  52. a parameter.
  53. 7. The callback function should then run. Note: it is a requirement that the
  54. callback function is small and non-blocking as it will be run in the context of
  55. a polling mechanism or an interrupt.
  56. 8. It is the application's responsibility via the callback function to schedule
  57. recalling the OpenSSL asynchronous function and to continue processing.
  58. 9. The callback function has the option to check the status returned via
  59. SSL_get_async_status() to determine whether a retry happened instead of the
  60. request being submitted, allowing different processing if required.
  61. =head1 RETURN VALUES
  62. SSL_CTX_set_async_callback(), SSL_set_async_callback(),
  63. SSL_CTX_set_async_callback_arg(), SSL_CTX_set_async_callback_arg() and
  64. SSL_get_async_status() return 1 on success or 0 on error.
  65. =head1 HISTORY
  66. SSL_CTX_set_async_callback(), SSL_CTX_set_async_callback_arg(),
  67. SSL_set_async_callback(), SSL_set_async_callback_arg() and
  68. SSL_get_async_status() were first added to OpenSSL 3.0.0.
  69. =head1 COPYRIGHT
  70. Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
  71. Licensed under the OpenSSL license (the "License"). You may not use
  72. this file except in compliance with the License. You can obtain a copy
  73. in the file LICENSE in the source distribution or at
  74. L<https://www.openssl.org/source/license.html>.
  75. =cut