1d2i_SSL_SESSION(3)                  OpenSSL                 d2i_SSL_SESSION(3)
2
3
4

NAME

6       d2i_SSL_SESSION, i2d_SSL_SESSION - convert SSL_SESSION object from/to
7       ASN1 representation
8

SYNOPSIS

10        #include <openssl/ssl.h>
11
12        SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length);
13        int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
14

DESCRIPTION

16       d2i_SSL_SESSION() transforms the external ASN1 representation of an
17       SSL/TLS session, stored as binary data at location pp with length
18       length, into an SSL_SESSION object.
19
20       i2d_SSL_SESSION() transforms the SSL_SESSION object in into the ASN1
21       representation and stores it into the memory location pointed to by pp.
22       The length of the resulting ASN1 representation is returned. If pp is
23       the NULL pointer, only the length is calculated and returned.
24

NOTES

26       The SSL_SESSION object is built from several malloc()ed parts, it can
27       therefore not be moved, copied or stored directly. In order to store
28       session data on disk or into a database, it must be transformed into a
29       binary ASN1 representation.
30
31       When using d2i_SSL_SESSION(), the SSL_SESSION object is automatically
32       allocated. The reference count is 1, so that the session must be
33       explicitly removed using SSL_SESSION_free(3), unless the SSL_SESSION
34       object is completely taken over, when being called inside the
35       get_session_cb() (see SSL_CTX_sess_set_get_cb(3)).
36
37       SSL_SESSION objects keep internal link information about the session
38       cache list, when being inserted into one SSL_CTX object's session
39       cache.  One SSL_SESSION object, regardless of its reference count, must
40       therefore only be used with one SSL_CTX object (and the SSL objects
41       created from this SSL_CTX object).
42
43       When using i2d_SSL_SESSION(), the memory location pointed to by pp must
44       be large enough to hold the binary representation of the session. There
45       is no known limit on the size of the created ASN1 representation, so
46       the necessary amount of space should be obtained by first calling
47       i2d_SSL_SESSION() with pp=NULL, and obtain the size needed, then
48       allocate the memory and call i2d_SSL_SESSION() again.  Note that this
49       will advance the value contained in *pp so it is necessary to save a
50       copy of the original allocation.  For example:
51        int i,j;
52        char *p, *temp;
53        i = i2d_SSL_SESSION(sess, NULL);
54        p = temp = malloc(i);
55        j = i2d_SSL_SESSION(sess, &temp);
56        assert(i == j);
57        assert(p+i == temp);
58

RETURN VALUES

60       d2i_SSL_SESSION() returns a pointer to the newly allocated SSL_SESSION
61       object. In case of failure the NULL-pointer is returned and the error
62       message can be retrieved from the error stack.
63
64       i2d_SSL_SESSION() returns the size of the ASN1 representation in bytes.
65       When the session is not valid, 0 is returned and no operation is
66       performed.
67

SEE ALSO

69       ssl(3), SSL_SESSION_free(3), SSL_CTX_sess_set_get_cb(3)
70
71
72
731.0.2o                            2020-08-01                d2i_SSL_SESSION(3)
Impressum