2
0

SSL_set_async_callback.pod 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 openssl 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 B<SSL>
  21. objects generated based on this B<SSL_CTX> will get this callback. If an engine
  22. supports the callback mechanism, it will be automatically called if
  23. B<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 B<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 B<SSL> object when the
  31. above 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. B<ASYNC_STATUS_UNSUPPORTED> will be returned. See ASYNC_WAIT_CTX_set_status()
  38. for a description of all of the status values.
  39. An example of the above functions would be the following:
  40. =over 4
  41. =item 1.
  42. Application sets the async callback and callback data on an SSL connection
  43. by calling SSL_set_async_callback().
  44. =item 2.
  45. Application sets B<SSL_MODE_ASYNC> and makes an asynchronous SSL call
  46. =item 3.
  47. OpenSSL submits the asynchronous request to the engine. If a retry occurs at
  48. this point then the status within the B<ASYNC_WAIT_CTX> would be set and the
  49. async callback function would be called (goto Step 7).
  50. =item 4.
  51. The OpenSSL engine pauses the current job and returns, so that the
  52. application can continue processing other connections.
  53. =item 5.
  54. At a future point in time (probably via a polling mechanism or via an
  55. interrupt) the engine will become aware that the asynchronous request has
  56. finished processing.
  57. =item 6.
  58. The engine will call the application's callback passing the callback data as
  59. a parameter.
  60. =item 7.
  61. The callback function should then run. Note: it is a requirement that the
  62. callback function is small and nonblocking as it will be run in the context of
  63. a polling mechanism or an interrupt.
  64. =item 8.
  65. It is the application's responsibility via the callback function to schedule
  66. recalling the OpenSSL asynchronous function and to continue processing.
  67. =item 9.
  68. The callback function has the option to check the status returned via
  69. SSL_get_async_status() to determine whether a retry happened instead of the
  70. request being submitted, allowing different processing if required.
  71. =back
  72. =head1 RETURN VALUES
  73. SSL_CTX_set_async_callback(), SSL_set_async_callback(),
  74. SSL_CTX_set_async_callback_arg(), SSL_CTX_set_async_callback_arg() and
  75. SSL_get_async_status() return 1 on success or 0 on error.
  76. =head1 SEE ALSO
  77. L<ssl(7)>
  78. =head1 HISTORY
  79. SSL_CTX_set_async_callback(), SSL_CTX_set_async_callback_arg(),
  80. SSL_set_async_callback(), SSL_set_async_callback_arg() and
  81. SSL_get_async_status() were first added to OpenSSL 3.0.
  82. =head1 COPYRIGHT
  83. Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  84. Licensed under the Apache License 2.0 (the "License"). You may not use
  85. this file except in compliance with the License. You can obtain a copy
  86. in the file LICENSE in the source distribution or at
  87. L<https://www.openssl.org/source/license.html>.
  88. =cut