1SSL_CTX_set_session_id_context(3) OpenSSL SSL_CTX_set_session_id_context(3)
2
3
4
6 SSL_CTX_set_session_id_context, SSL_set_session_id_context - set con‐
7 text within which session can be reused (server side only)
8
10 #include <openssl/ssl.h>
11
12 int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,
13 unsigned int sid_ctx_len);
14 int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,
15 unsigned int sid_ctx_len);
16
18 SSL_CTX_set_session_id_context() sets the context sid_ctx of length
19 sid_ctx_len within which a session can be reused for the ctx object.
20
21 SSL_set_session_id_context() sets the context sid_ctx of length
22 sid_ctx_len within which a session can be reused for the ssl object.
23
25 Sessions are generated within a certain context. When exporting/import‐
26 ing sessions with i2d_SSL_SESSION/d2i_SSL_SESSION it would be possible,
27 to re-import a session generated from another context (e.g. another
28 application), which might lead to malfunctions. Therefore each applica‐
29 tion must set its own session id context sid_ctx which is used to dis‐
30 tinguish the contexts and is stored in exported sessions. The sid_ctx
31 can be any kind of binary data with a given length, it is therefore
32 possible to use e.g. the name of the application and/or the hostname
33 and/or service name ...
34
35 The session id context becomes part of the session. The session id con‐
36 text is set by the SSL/TLS server. The SSL_CTX_set_session_id_context()
37 and SSL_set_session_id_context() functions are therefore only useful on
38 the server side.
39
40 OpenSSL clients will check the session id context returned by the
41 server when reusing a session.
42
43 The maximum length of the sid_ctx is limited to SSL_MAX_SSL_SES‐
44 SION_ID_LENGTH.
45
47 If the session id context is not set on an SSL/TLS server and client
48 certificates are used, stored sessions will not be reused but a fatal
49 error will be flagged and the handshake will fail.
50
51 If a server returns a different session id context to an OpenSSL client
52 when reusing a session, an error will be flagged and the handshake will
53 fail. OpenSSL servers will always return the correct session id con‐
54 text, as an OpenSSL server checks the session id context itself before
55 reusing a session as described above.
56
58 SSL_CTX_set_session_id_context() and SSL_set_session_id_context()
59 return the following values:
60
61 0 The length sid_ctx_len of the session id context sid_ctx exceeded
62 the maximum allowed length of SSL_MAX_SSL_SESSION_ID_LENGTH. The
63 error is logged to the error stack.
64
65 1 The operation succeeded.
66
68 ssl(3)
69
70
71
720.9.8b 2004-06-14 SSL_CTX_set_session_id_context(3)