blob: a84e4a6773485eba2563a6d2d96d3c716ca35179 [file] [log] [blame]
Emeric Brun3e541d12012-09-03 11:14:36 +02001/*
2 * shctx.h - shared context management functions for SSL
3 *
4 * Copyright (C) 2011-2012 EXCELIANCE
5 *
6 * Author: Emeric Brun - emeric@exceliance.fr
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13
14#ifndef SHCTX_H
15#define SHCTX_H
16#include <openssl/ssl.h>
17#include <stdint.h>
18
Emeric Brunaf9619d2012-11-28 18:47:52 +010019#ifndef SHSESS_BLOCK_MIN_SIZE
20#define SHSESS_BLOCK_MIN_SIZE 128
Emeric Brun3e541d12012-09-03 11:14:36 +020021#endif
22
23#ifndef SHSESS_MAX_DATA_LEN
Emeric Brunaf9619d2012-11-28 18:47:52 +010024#define SHSESS_MAX_DATA_LEN 4096
Emeric Brun3e541d12012-09-03 11:14:36 +020025#endif
26
Emeric Brun786991e2012-11-26 18:37:12 +010027#ifndef SHCTX_APPNAME
28#define SHCTX_APPNAME "haproxy"
29#endif
30
Emeric Brun3e541d12012-09-03 11:14:36 +020031/* Allocate shared memory context.
Emeric Brunaf9619d2012-11-28 18:47:52 +010032 * <size> is the number of allocated blocks into cache (default 128 bytes)
33 * A block is large enough to contain a classic session (without client cert)
Emeric Brun22890a12012-12-28 14:41:32 +010034 * If <size> is set less or equal to 0, ssl cache is disabled.
Emeric Brunaf9619d2012-11-28 18:47:52 +010035 * Set <use_shared_memory> to 1 to use a mapped shared memory instead
36 * of private. (ignored if compiled with USE_PRIVATE_CACHE=1).
37 * Returns: -1 on alloc failure, <size> if it performs context alloc,
38 * and 0 if cache is already allocated.
39 */
Emeric Brun4b3091e2012-09-24 15:48:52 +020040int shared_context_init(int size, int use_shared_memory);
Emeric Brun3e541d12012-09-03 11:14:36 +020041
42/* Set shared cache callbacks on an ssl context.
43 * Set session cache mode to server and disable openssl internal cache.
44 * Shared context MUST be firstly initialized */
45void shared_context_set_cache(SSL_CTX *ctx);
46
47#endif /* SHCTX_H */
48