2
0

d2i_SSL_SESSION.pod 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. =pod
  2. =head1 NAME
  3. d2i_SSL_SESSION, i2d_SSL_SESSION - convert SSL_SESSION object from/to ASN1 representation
  4. =head1 SYNOPSIS
  5. #include <openssl/ssl.h>
  6. SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length);
  7. int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
  8. =head1 DESCRIPTION
  9. d2i_SSL_SESSION() transforms the external ASN1 representation of an SSL/TLS
  10. session, stored as binary data at location B<pp> with length B<length>, into
  11. an SSL_SESSION object.
  12. i2d_SSL_SESSION() transforms the SSL_SESSION object B<in> into the ASN1
  13. representation and stores it into the memory location pointed to by B<pp>.
  14. The length of the resulting ASN1 representation is returned. If B<pp> is
  15. the NULL pointer, only the length is calculated and returned.
  16. =head1 NOTES
  17. The SSL_SESSION object is built from several malloc()ed parts, it can
  18. therefore not be moved, copied or stored directly. In order to store
  19. session data on disk or into a database, it must be transformed into
  20. a binary ASN1 representation.
  21. When using d2i_SSL_SESSION(), the SSL_SESSION object is automatically
  22. allocated. The reference count is 1, so that the session must be
  23. explicitly removed using L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
  24. unless the SSL_SESSION object is completely taken over, when being called
  25. inside the get_session_cb() (see
  26. L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>).
  27. SSL_SESSION objects keep internal link information about the session cache
  28. list, when being inserted into one SSL_CTX object's session cache.
  29. One SSL_SESSION object, regardless of its reference count, must therefore
  30. only be used with one SSL_CTX object (and the SSL objects created
  31. from this SSL_CTX object).
  32. When using i2d_SSL_SESSION(), the memory location pointed to by B<pp> must be
  33. large enough to hold the binary representation of the session. There is no
  34. known limit on the size of the created ASN1 representation, so the necessary
  35. amount of space should be obtained by first calling i2d_SSL_SESSION() with
  36. B<pp=NULL>, and obtain the size needed, then allocate the memory and
  37. call i2d_SSL_SESSION() again.
  38. Note that this will advance the value contained in B<*pp> so it is necessary
  39. to save a copy of the original allocation.
  40. For example:
  41. int i,j;
  42. char *p, *temp;
  43. i = i2d_SSL_SESSION(sess, NULL);
  44. p = temp = malloc(i);
  45. j = i2d_SSL_SESSION(sess, &temp);
  46. assert(i == j);
  47. assert(p+i == temp);
  48. =head1 RETURN VALUES
  49. d2i_SSL_SESSION() returns a pointer to the newly allocated SSL_SESSION
  50. object. In case of failure the NULL-pointer is returned and the error message
  51. can be retrieved from the error stack.
  52. i2d_SSL_SESSION() returns the size of the ASN1 representation in bytes.
  53. When the session is not valid, B<0> is returned and no operation is performed.
  54. =head1 SEE ALSO
  55. L<ssl(3)|ssl(3)>, L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
  56. L<SSL_CTX_sess_set_get_cb(3)|SSL_CTX_sess_set_get_cb(3)>
  57. =cut