SSL_get_session.pod 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. =pod
  2. =head1 NAME
  3. SSL_get_session - retrieve TLS/SSL session data
  4. =head1 SYNOPSIS
  5. #include <openssl/ssl.h>
  6. SSL_SESSION *SSL_get_session(const SSL *ssl);
  7. SSL_SESSION *SSL_get0_session(const SSL *ssl);
  8. SSL_SESSION *SSL_get1_session(SSL *ssl);
  9. =head1 DESCRIPTION
  10. SSL_get_session() returns a pointer to the B<SSL_SESSION> actually used in
  11. B<ssl>. The reference count of the B<SSL_SESSION> is not incremented, so
  12. that the pointer can become invalid by other operations.
  13. SSL_get0_session() is the same as SSL_get_session().
  14. SSL_get1_session() is the same as SSL_get_session(), but the reference
  15. count of the B<SSL_SESSION> is incremented by one.
  16. =head1 NOTES
  17. The ssl session contains all information required to re-establish the
  18. connection without a new handshake.
  19. SSL_get0_session() returns a pointer to the actual session. As the
  20. reference counter is not incremented, the pointer is only valid while
  21. the connection is in use. If L<SSL_clear(3)|SSL_clear(3)> or
  22. L<SSL_free(3)|SSL_free(3)> is called, the session may be removed completely
  23. (if considered bad), and the pointer obtained will become invalid. Even
  24. if the session is valid, it can be removed at any time due to timeout
  25. during L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>.
  26. If the data is to be kept, SSL_get1_session() will increment the reference
  27. count, so that the session will not be implicitly removed by other operations
  28. but stays in memory. In order to remove the session
  29. L<SSL_SESSION_free(3)|SSL_SESSION_free(3)> must be explicitly called once
  30. to decrement the reference count again.
  31. SSL_SESSION objects keep internal link information about the session cache
  32. list, when being inserted into one SSL_CTX object's session cache.
  33. One SSL_SESSION object, regardless of its reference count, must therefore
  34. only be used with one SSL_CTX object (and the SSL objects created
  35. from this SSL_CTX object).
  36. =head1 RETURN VALUES
  37. The following return values can occur:
  38. =over 4
  39. =item NULL
  40. There is no session available in B<ssl>.
  41. =item Pointer to an SSL
  42. The return value points to the data of an SSL session.
  43. =back
  44. =head1 SEE ALSO
  45. L<ssl(3)|ssl(3)>, L<SSL_free(3)|SSL_free(3)>,
  46. L<SSL_clear(3)|SSL_clear(3)>,
  47. L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>
  48. =cut