SSL_CTX_set_session_ticket_cb.pod 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_session_ticket_cb,
  4. SSL_SESSION_get0_ticket_appdata,
  5. SSL_SESSION_set1_ticket_appdata,
  6. SSL_CTX_generate_session_ticket_fn,
  7. SSL_CTX_decrypt_session_ticket_fn - manage session ticket application data
  8. =head1 SYNOPSIS
  9. #include <openssl/ssl.h>
  10. typedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg);
  11. typedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss,
  12. const unsigned char *keyname,
  13. size_t keyname_len,
  14. SSL_TICKET_RETURN retv,
  15. void *arg);
  16. int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx,
  17. SSL_CTX_generate_session_ticket_fn gen_cb,
  18. SSL_CTX_decrypt_session_ticket_fn dec_cb,
  19. void *arg);
  20. int SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len);
  21. int SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len);
  22. =head1 DESCRIPTION
  23. SSL_CTX_set_set_session_ticket_cb() sets the application callbacks B<gen_cb>
  24. and B<dec_cb> that are used by a server to set and get application data stored
  25. with a session, and placed into a session ticket. Either callback function may
  26. be set to NULL. The value of B<arg> is passed to the callbacks.
  27. B<gen_cb> is the application defined callback invoked when a session ticket is
  28. about to be created. The application can call SSL_SESSION_set1_ticket_appdata()
  29. at this time to add application data to the session ticket. The value of B<arg>
  30. is the same as that given to SSL_CTX_set_session_ticket_cb(). The B<gen_cb>
  31. callback is defined as type B<SSL_CTX_generate_session_ticket_fn>.
  32. B<dec_cb> is the application defined callback invoked after session ticket
  33. decryption has been attempted and any session ticket application data is available.
  34. The application can call SSL_SESSION_get_ticket_appdata() at this time to retrieve
  35. the application data. The value of B<arg> is the same as that given to
  36. SSL_CTX_set_session_ticket_cb(). The B<retv> argument is the result of the ticket
  37. decryption. The B<keyname> and B<keyname_len> identify the key used to decrypt the
  38. session ticket. The B<dec_cb> callback is defined as type
  39. B<SSL_CTX_decrypt_session_ticket_fn>.
  40. SSL_SESSION_set1_ticket_appdata() sets the application data specified by
  41. B<data> and B<len> into B<ss> which is then placed into any generated session
  42. tickets. It can be called at any time before a session ticket is created to
  43. update the data placed into the session ticket. However, given that sessions
  44. and tickets are created by the handshake, the B<gen_cb> is provided to notify
  45. the application that a session ticket is about to be generated.
  46. SSL_SESSION_get0_ticket_appdata() assigns B<data> to the session ticket
  47. application data and assigns B<len> to the length of the session ticket
  48. application data from B<ss>. The application data can be set via
  49. SSL_SESSION_set1_ticket_appdata() or by a session ticket. NULL will be assigned
  50. to B<data> and 0 will be assigned to B<len> if there is no session ticket
  51. application data. SSL_SESSION_get0_ticket_appdata() can be called any time
  52. after a session has been created. The B<dec_cb> is provided to notify the
  53. application that a session ticket has just been decrypted.
  54. =head1 NOTES
  55. When the B<dec_cb> callback is invoked, the SSL_SESSION B<ss> has not yet been
  56. assigned to the SSL B<s>. The B<retv> indicates the result of the ticket
  57. decryption which can be modified by the callback before being returned. The
  58. callback must check the B<retv> value before performing any action, as it's
  59. called even if ticket decryption fails.
  60. The B<keyname> and B<keyname_len> arguments to B<dec_cb> may be used to identify
  61. the key that was used to encrypt the session ticket.
  62. When the B<gen_cb> callback is invoked, the SSL_get_session() function can be
  63. used to retrieve the SSL_SESSION for SSL_SESSION_set1_ticket_appdata().
  64. =head1 RETURN VALUES
  65. The SSL_CTX_set_session_ticket_cb(), SSL_SESSION_set1_ticket_appdata() and
  66. SSL_SESSION_get0_ticket_appdata() functions return 1 on success and 0 on
  67. failure.
  68. The B<gen_cb> callback must return 1 to continue the connection. A return of 0
  69. will terminate the connection with an INTERNAL_ERROR alert.
  70. The B<dec_cb> callback must return one of the following B<SSL_TICKET_RETURN>
  71. values. Under normal circumstances the B<retv> value is returned unmodified,
  72. but the callback can change the behavior of the post-ticket decryption code
  73. by returning something different. The B<dec_cb> callback must check the B<retv>
  74. value before performing any action.
  75. typedef int SSL_TICKET_RETURN;
  76. =over 4
  77. =item SSL_TICKET_FATAL_ERR_MALLOC
  78. Fatal error, malloc failure.
  79. =item SSL_TICKET_FATAL_ERR_OTHER
  80. Fatal error, either from parsing or decrypting the ticket.
  81. =item SSL_TICKET_NONE
  82. No ticket present.
  83. =item SSL_TICKET_EMPTY
  84. Empty ticket present.
  85. =item SSL_TICKET_NO_DECRYPT
  86. The ticket couldn't be decrypted.
  87. =item SSL_TICKET_SUCCESS
  88. A ticket was successfully decrypted, any session ticket application data should
  89. be available.
  90. =item TICKET_SUCCESS_RENEW
  91. Same as B<TICKET_SUCCESS>, but the ticket needs to be renewed.
  92. =back
  93. =head1 SEE ALSO
  94. L<ssl(7)>,
  95. L<SSL_get_session(3)>
  96. =head1 HISTORY
  97. SSL_CTX_set_session_ticket_cb(), SSSL_SESSION_set1_ticket_appdata() and
  98. SSL_SESSION_get_ticket_appdata() were added to OpenSSL 1.1.1.
  99. =head1 COPYRIGHT
  100. Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  101. Licensed under the OpenSSL license (the "License"). You may not use
  102. this file except in compliance with the License. You can obtain a copy
  103. in the file LICENSE in the source distribution or at
  104. L<https://www.openssl.org/source/license.html>.
  105. =cut