Manual Pages for UNIX Darwin command on man SSL_CTX_set_generate_session_id
MyWebUniversity

Manual Pages for UNIX Darwin command on man SSL_CTX_set_generate_session_id

SSLCTXsetgeneratesessionid(3) OpenSSL SSLCTXsetgeneratesessionid(3)

NAME

SSLCTXsetgeneratesessionid, SSLsetgeneratesessionid,

SSLhasmatchingsessionid - manipulate generation of SSL session IDs

(server only)

SYNOPSIS

#include

typedef int (*GENSESSIONCB)(const SSL *ssl, unsigned char *id, unsigned int *idlen); int SSLCTXsetgeneratesessionid(SSLCTX *ctx, GENSESSIONCB cb); int SSLsetgeneratesessionid(SSL *ssl, GENSESSIONCB, cb); int SSLhasmatchingsessionid(const SSL *ssl, const unsigned char *id, unsigned int idlen);

DESCRIPTION

SSLCTXsetgeneratesessionid() sets the callback function for generating new session ids for SSL/TLS sessions for ccttxx to be ccbb. SSLsetgeneratesessionid() sets the callback function for generating new session ids for SSL/TLS sessions for ssssll to be ccbb. SSLhasmatchingsessionid() checks, whether a session with id iidd (of length iiddlleenn) is already contained in the internal session cache of the parent context of ssssll. NNOOTTEESS When a new session is established between client and server, the server generates a session id. The session id is an arbitrary sequence of bytes. The length of the session id is 16 bytes for SSLv2 sessions and between 1 and 32 bytes for SSLv3/TLSv1. The session id is not security critical but must be unique for the server. Additionally, the session id is transmitted in the clear when reusing the session so it must not contain sensitive information. Without a callback being set, an OpenSSL server will generate a unique session id from pseudo random numbers of the maximum possible length. Using the callback function, the session id can be changed to contain additional information like e.g. a host id in order to improve load balancing or external caching techniques. The callback function receives a pointer to the memory location to put iidd into and a pointer to the maximum allowed length iiddlleenn. The buffer at location iidd is only guaranteed to have the size iiddlleenn. The callback is only allowed to generate a shorter id and reduce iiddlleenn; the callback mmuusstt nneevveerr increase iiddlleenn or write to the location iidd exceeding the given limit. If a SSLv2 session id is generated and iiddlleenn is reduced, it will be restored after the callback has finished and the session id will be padded with 0x00. It is not recommended to change the iiddlleenn for SSLv2 sessions. The callback can use the SSLgetversion(3) function to check, whether the session is of type SSLv2. The location iidd is filled with 0x00 before the callback is called, so the callback may only fill part of the possible length and leave iiddlleenn untouched while maintaining reproducibility. Since the sessions must be distinguished, session ids must be unique. Without the callback a random number is used, so that the probability of generating the same session id is extremely small (2^128 possible ids for an SSLv2 session, 2^256 for SSLv3/TLSv1). In order to assure the uniqueness of the generated session id, the callback must call SSLhasmatchingsessionid() and generate another id if a conflict occurs. If an id conflict is not resolved, the handshake will fail. If the application codes e.g. a unique host id, a unique process number, and a unique sequence number into the session id, uniqueness could easily be achieved without randomness added (it should however be taken care that no confidential information is leaked this way). If the application can not guarantee uniqueness, it is recommended to use the maximum iiddlleenn and fill in the bytes not used to code special information with random data to avoid collisions. SSLhasmatchingsessionid() will only query the internal session cache, not the external one. Since the session id is generated before the handshake is completed, it is not immediately added to the cache. If another thread is using the same internal session cache, a race condition can occur in that another thread generates the same session id. Collisions can also occur when using an external session cache, since the external cache is not tested with SSLhasmatchingsessionid() and the same race condition applies. When calling SSLhasmatchingsessionid() for an SSLv2 session with reduced iiddlleenn, the match operation will be performed using the fixed length required and with a 0x00 padded id. The callback must return 0 if it cannot generate a session id for whatever reason and return 1 on success. EEXXAAMMPPLLEESS The callback function listed will generate a session id with the server id given, and will fill the rest with pseudo random bytes:

const char sessionidprefix = "www-18";

#define MAXSESSIONIDATTEMPTS 10

static int generatesessionid(const SSL *ssl, unsigned char *id, unsigned int *idlen) { unsigned int count = 0; const char *version; version = SSLgetversion(ssl); if (!strcmp(version, "SSLv2")) /* we must not change idlen */; do { RANDpseudobytes(id, *idlen); /* Prefix the sessionid with the required prefix. NB: If our

* prefix is too long, clip it - but there will be worse effects

* anyway, eg. the server could only possibly create 1 session * ID (ie. the prefix!) so all future session negotiations will * fail due to conflicts. */ memcpy(id, sessionidprefix, (strlen(sessionidprefix) < *idlen) ? strlen(sessionidprefix) : *idlen); } while(SSLhasmatchingsessionid(ssl, id, *idlen) && (++count < MAXSESSIONIDATTEMPTS)); if(count >= MAXSESSIONIDATTEMPTS) return 0; return 1; }

RETURN VALUES

SSLCTXsetgeneratesessionid() and SSLsetgeneratesessionid() always return 1. SSLhasmatchingsessionid() returns 1 if another session with the same id is already in the cache.

SEE ALSO

ssl(3), SSLgetversion(3) HISTORY SSLCTXsetgeneratesessionid(), SSLsetgeneratesessionid() and SSLhasmatchingsessionid() have been introduced in OpenSSL 0.9.7.

0.9.7l 2001-02-23SSLCTXsetgeneratesessionid(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™