summaryrefslogtreecommitdiff
path: root/src/lib/libssl/doc/d2i_SSL_SESSION.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/doc/d2i_SSL_SESSION.3')
-rw-r--r--src/lib/libssl/doc/d2i_SSL_SESSION.3126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/d2i_SSL_SESSION.3 b/src/lib/libssl/doc/d2i_SSL_SESSION.3
new file mode 100644
index 0000000000..3a40c32e69
--- /dev/null
+++ b/src/lib/libssl/doc/d2i_SSL_SESSION.3
@@ -0,0 +1,126 @@
1.Dd $Mdocdate: October 12 2014 $
2.Dt D2I_SSL_SESSION 3
3.Os
4.Sh NAME
5.Nm d2i_SSL_SESSION ,
6.Nm i2d_SSL_SESSION
7.Nd convert SSL_SESSION object from/to ASN1 representation
8.Sh SYNOPSIS
9.In openssl/ssl.h
10.Ft SSL_SESSION *
11.Fn d2i_SSL_SESSION "SSL_SESSION **a" "const unsigned char **pp" "long length"
12.Ft int
13.Fn i2d_SSL_SESSION "SSL_SESSION *in" "unsigned char **pp"
14.Sh DESCRIPTION
15.Fn d2i_SSL_SESSION
16transforms the external ASN1 representation of an SSL/TLS session,
17stored as binary data at location
18.Fa pp
19with length
20.Fa length ,
21into
22an
23.Vt SSL_SESSION
24object.
25.Pp
26.Fn i2d_SSL_SESSION
27transforms the
28.Vt SSL_SESSION
29object
30.Fa in
31into the ASN1 representation and stores it into the memory location pointed to
32by
33.Fa pp .
34The length of the resulting ASN1 representation is returned.
35If
36.Fa pp
37is the
38.Dv NULL
39pointer, only the length is calculated and returned.
40.Sh NOTES
41The
42.Vt SSL_SESSION
43object is built from several
44.Xr malloc 3 Ns
45-ed parts; it can therefore not be moved, copied or stored directly.
46In order to store session data on disk or into a database,
47it must be transformed into a binary ASN1 representation.
48.Pp
49When using
50.Fn d2i_SSL_SESSION ,
51the
52.Vt SSL_SESSION
53object is automatically allocated.
54The reference count is 1, so that the session must be explicitly removed using
55.Xr SSL_SESSION_free 3 ,
56unless the
57.Vt SSL_SESSION
58object is completely taken over, when being called inside the
59.Xr get_session_cb 3
60(see
61.Xr SSL_CTX_sess_set_get_cb 3 ) .
62.Pp
63.Vt SSL_SESSION
64objects keep internal link information about the session cache list when being
65inserted into one
66.Vt SSL_CTX
67object's session cache.
68One
69.Vt SSL_SESSION
70object, regardless of its reference count, must therefore only be used with one
71.Vt SSL_CTX
72object (and the
73.Vt SSL
74objects created from this
75.Vt SSL_CTX
76object).
77.Pp
78When using
79.Fn i2d_SSL_SESSION ,
80the memory location pointed to by
81.Fa pp
82must be large enough to hold the binary representation of the session.
83There is no known limit on the size of the created ASN1 representation,
84so the necessary amount of space should be obtained by first calling
85.Fn i2d_SSL_SESSION
86with
87.Fa pp Ns
88= Ns
89.Dv NULL ,
90and obtain the size needed, then allocate the memory and call
91.Fn i2d_SSL_SESSION
92again.
93Note that this will advance the value contained in
94.Fa *pp
95so it is necessary to save a copy of the original allocation.
96For example:
97.Bd -literal
98int i, j;
99
100char *p, *temp;
101
102 i = i2d_SSL_SESSION(sess, NULL);
103 p = temp = malloc(i);
104 if (temp != NULL) {
105 j = i2d_SSL_SESSION(sess, &temp);
106 assert(i == j);
107 assert(p + i == temp);
108 }
109.Ed
110.Sh RETURN VALUES
111.Fn d2i_SSL_SESSION
112returns a pointer to the newly allocated
113.Vt SSL_SESSION
114object.
115In case of failure a
116.Dv NULL
117pointer is returned and the error message can be retrieved from the error
118stack.
119.Pp
120.Fn i2d_SSL_SESSION
121returns the size of the ASN1 representation in bytes.
122When the session is not valid, 0 is returned and no operation is performed.
123.Sh SEE ALSO
124.Xr ssl 3 ,
125.Xr SSL_CTX_sess_set_get_cb 3 ,
126.Xr SSL_SESSION_free 3