d2i_SSL_SESSION(3) OpenSSL d2i_SSL_SESSION(3) NNAAMMEE d2i_SSL_SESSION, i2d_SSL_SESSION - convert SSL_SESSION object from/to ASN1 representation SSYYNNOOPPSSIISS #include SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length); int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp); DDEESSCCRRIIPPTTIIOONN _d_2_i___S_S_L___S_E_S_S_I_O_N_(_) transforms the external ASN1 representation of an SSL/TLS session, stored as binary data at location pppp with length lleennggtthh, into an SSL_SESSION object. _i_2_d___S_S_L___S_E_S_S_I_O_N_(_) transforms the SSL_SESSION object iinn into the ASN1 representation and stores it into the memory location pointed to by pppp. The length of the resulting ASN1 representation is returned. If pppp is the NULL pointer, only the length is calculated and returned. NNOOTTEESS The SSL_SESSION object is built from several _m_a_l_l_o_c_(_)ed parts, it can therefore not be moved, copied or stored directly. In order to store session data on disk or into a database, it must be transformed into a binary ASN1 representation. When using _d_2_i___S_S_L___S_E_S_S_I_O_N_(_), the SSL_SESSION object is automatically allocated. The reference count is 1, so that the session must be explicitly removed using _S_S_L___S_E_S_S_I_O_N___f_r_e_e(3), unless the SSL_SESSION object is completely taken over, when being called inside the _g_e_t___s_e_s_- _s_i_o_n___c_b_(_) (see _S_S_L___C_T_X___s_e_s_s___s_e_t___g_e_t___c_b(3)). SSL_SESSION objects keep internal link information about the session cache list, when being inserted into one SSL_CTX object's session cache. One SSL_SESSION object, regardless of its reference count, must therefore only be used with one SSL_CTX object (and the SSL objects created from this SSL_CTX object). When using _i_2_d___S_S_L___S_E_S_S_I_O_N_(_), the memory location pointed to by pppp must be large enough to hold the binary representation of the session. There is no known limit on the size of the created ASN1 representation, so the necessary amount of space should be obtained by first calling _i_2_d___S_S_L___S_E_S_S_I_O_N_(_) with pppp==NNUULLLL, and obtain the size needed, then allo- cate the memory and call _i_2_d___S_S_L___S_E_S_S_I_O_N_(_) again. Note that this will advance the value contained in **pppp so it is necessary to save a copy of the original allocation. For example: int i,j; char *p, *temp; i = i2d_SSL_SESSION(sess, NULL); p = temp = malloc(i); j = i2d_SSL_SESSION(sess, &temp); assert(i == j); assert(p+i == temp); RREETTUURRNN VVAALLUUEESS _d_2_i___S_S_L___S_E_S_S_I_O_N_(_) returns a pointer to the newly allocated SSL_SESSION object. In case of failure the NULL-pointer is returned and the error message can be retrieved from the error stack. _i_2_d___S_S_L___S_E_S_S_I_O_N_(_) returns the size of the ASN1 representation in bytes. When the session is not valid, 00 is returned and no operation is per- formed. SSEEEE AALLSSOO _s_s_l(3), _S_S_L___S_E_S_S_I_O_N___f_r_e_e(3), _S_S_L___C_T_X___s_e_s_s___s_e_t___g_e_t___c_b(3) 1.0.1u 2016-09-22 d2i_SSL_SESSION(3)