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
7 context 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
26 exporting/importing sessions with i2d_SSL_SESSION/d2i_SSL_SESSION it
27 would be possible, to re-import a session generated from another
28 context (e.g. another application), which might lead to malfunctions.
29 Therefore each application must set its own session id context sid_ctx
30 which is used to distinguish the contexts and is stored in exported
31 sessions. The sid_ctx can be any kind of binary data with a given
32 length, it is therefore possible to use e.g. the name of the
33 application and/or the hostname and/or service name ...
34
35 The session id context becomes part of the session. The session id
36 context is set by the SSL/TLS server. The
37 SSL_CTX_set_session_id_context() and SSL_set_session_id_context()
38 functions are therefore only useful on 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_SID_CTX_LENGTH.
44
46 If the session id context is not set on an SSL/TLS server and client
47 certificates are used, stored sessions will not be reused but a fatal
48 error will be flagged and the handshake will fail.
49
50 If a server returns a different session id context to an OpenSSL client
51 when reusing a session, an error will be flagged and the handshake will
52 fail. OpenSSL servers will always return the correct session id
53 context, as an OpenSSL server checks the session id context itself
54 before reusing a session as described above.
55
57 SSL_CTX_set_session_id_context() and SSL_set_session_id_context()
58 return the following values:
59
60 0 The length sid_ctx_len of the session id context sid_ctx exceeded
61 the maximum allowed length of SSL_MAX_SID_CTX_LENGTH. The error is
62 logged to the error stack.
63
64 1 The operation succeeded.
65
67 ssl(7)
68
70 Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
71
72 Licensed under the OpenSSL license (the "License"). You may not use
73 this file except in compliance with the License. You can obtain a copy
74 in the file LICENSE in the source distribution or at
75 <https://www.openssl.org/source/license.html>.
76
77
78
791.1.1d 2019-10-03 SSL_CTX_SET_SESSION_ID_CONTEXT(3)