| 
									
										
										
										
											2001-01-31 22:14:20 +08:00
										 |  |  | =pod | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 NAME | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SSL_CTX_set_session_id_context, SSL_set_session_id_context - set context within which session can be reused (server side only) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 SYNOPSIS | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  #include <openssl/ssl.h> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, | 
					
						
							|  |  |  |                                     unsigned int sid_ctx_len); | 
					
						
							|  |  |  |  int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx, | 
					
						
							|  |  |  |                                 unsigned int sid_ctx_len); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 DESCRIPTION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SSL_CTX_set_session_id_context() sets the context B<sid_ctx> of length | 
					
						
							|  |  |  | B<sid_ctx_len> within which a session can be reused for the B<ctx> object. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SSL_set_session_id_context() sets the context B<sid_ctx> of length | 
					
						
							|  |  |  | B<sid_ctx_len> within which a session can be reused for the B<ssl> object. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 NOTES | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Sessions are generated within a certain context. When exporting/importing | 
					
						
							|  |  |  | sessions with B<i2d_SSL_SESSION>/B<d2i_SSL_SESSION> it would be possible, | 
					
						
							|  |  |  | to re-import a session generated from another context (e.g. another | 
					
						
							|  |  |  | application), which might lead to malfunctions. Therefore each application | 
					
						
							|  |  |  | must set its own session id context B<sid_ctx> which is used to distinguish | 
					
						
							|  |  |  | the contexts and is stored in exported sessions. The B<sid_ctx> can be | 
					
						
							|  |  |  | any kind of binary data with a given length, it is therefore possible | 
					
						
							|  |  |  | to use e.g. the name of the application and/or the hostname and/or service | 
					
						
							|  |  |  | name ... | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The session id context becomes part of the session. The session id context | 
					
						
							|  |  |  | is set by the SSL/TLS server. The SSL_CTX_set_session_id_context() and | 
					
						
							|  |  |  | SSL_set_session_id_context() functions are therefore only useful on the | 
					
						
							|  |  |  | server side. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | OpenSSL clients will check the session id context returned by the server | 
					
						
							|  |  |  | when reusing a session. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The maximum length of the B<sid_ctx> is limited to | 
					
						
							| 
									
										
										
										
											2019-07-15 21:55:13 +08:00
										 |  |  | B<SSL_MAX_SID_CTX_LENGTH>. | 
					
						
							| 
									
										
										
										
											2001-01-31 22:14:20 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =head1 WARNINGS | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-14 21:27:28 +08:00
										 |  |  | If the session id context is not set on an SSL/TLS server and client | 
					
						
							|  |  |  | certificates are used, stored sessions | 
					
						
							| 
									
										
										
										
											2001-01-31 22:14:20 +08:00
										 |  |  | will not be reused but a fatal error will be flagged and the handshake | 
					
						
							|  |  |  | will fail. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | If a server returns a different session id context to an OpenSSL client | 
					
						
							|  |  |  | when reusing a session, an error will be flagged and the handshake will | 
					
						
							|  |  |  | fail. OpenSSL servers will always return the correct session id context, | 
					
						
							|  |  |  | as an OpenSSL server checks the session id context itself before reusing | 
					
						
							|  |  |  | a session as described above. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 RETURN VALUES | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SSL_CTX_set_session_id_context() and SSL_set_session_id_context() | 
					
						
							|  |  |  | return the following values: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =over 4 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-21 17:03:01 +08:00
										 |  |  | =item Z<>0 | 
					
						
							| 
									
										
										
										
											2001-01-31 22:14:20 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | The length B<sid_ctx_len> of the session id context B<sid_ctx> exceeded | 
					
						
							| 
									
										
										
										
											2019-07-15 21:55:13 +08:00
										 |  |  | the maximum allowed length of B<SSL_MAX_SID_CTX_LENGTH>. The error | 
					
						
							| 
									
										
										
										
											2001-01-31 22:14:20 +08:00
										 |  |  | is logged to the error stack. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-21 17:03:01 +08:00
										 |  |  | =item Z<>1 | 
					
						
							| 
									
										
										
										
											2001-01-31 22:14:20 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | The operation succeeded. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =back | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 SEE ALSO | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-11 16:33:09 +08:00
										 |  |  | L<ssl(7)> | 
					
						
							| 
									
										
										
										
											2001-01-31 22:14:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-18 23:44:05 +08:00
										 |  |  | =head1 COPYRIGHT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-06 21:04:44 +08:00
										 |  |  | Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							| 
									
										
										
										
											2016-05-18 23:44:05 +08:00
										 |  |  | this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  | in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  | L<https://www.openssl.org/source/license.html>. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =cut |