5
#ifndef SQUID_SSL_CONTEXT_STORAGE_H
6
#define SQUID_SSL_CONTEXT_STORAGE_H
10
#include "SquidTime.h"
11
#include "CacheManager.h"
19
/// TODO: Replace on real size.
20
#define SSL_CTX_SIZE 1024
25
/** Reports cached SSL certificate stats to Cache Manager.
26
* TODO: Use "Report" functions instead friend class.
28
class CertificateStorageAction : public CacheManagerAction
31
CertificateStorageAction();
32
virtual void run (StoreEntry *sentry);
36
* Memory cache for store generated SSL context. Enforces total size limits
37
* using an LRU algorithm.
39
class LocalContextStorage
41
friend class CertificateStorageAction;
43
/// Cache item is an (SSL_CTX, host name) tuple.
47
Item(SSL_CTX * aSsl_ctx, std::string const & aName);
50
SSL_CTX * ssl_ctx; ///< The SSL context.
51
std::string host_name; ///< The host name of the SSL context.
54
typedef std::list<Item *> Queue;
55
typedef Queue::iterator QueueIterator;
57
/// host_name:queue_item mapping for fast lookups by host name
58
typedef std::map<std::string, QueueIterator> Map;
59
typedef Map::iterator MapIterator;
60
typedef std::pair<std::string, QueueIterator> MapPair;
62
LocalContextStorage(size_t aMax_memory);
63
~LocalContextStorage();
64
/// Set maximum memory size for this storage.
65
void SetSize(size_t aMax_memory);
66
/// Return a pointer to the added ssl_ctx or NULL if fails (eg. max cache size equal 0).
67
SSL_CTX * add(char const * host_name, SSL_CTX * ssl_ctx);
68
/// Find SSL_CTX in storage by host name. Lru queue will be updated.
69
SSL_CTX * find(char const * host_name);
70
void remove(char const * host_name); ///< Delete the SSL context by hostname
73
void purgeOne(); ///< Delete oldest object.
74
/// Delete object by iterator. It is used in deletePurge() and remove(...) methods.
75
void deleteAt(MapIterator i);
77
size_t max_memory; ///< Max cache size.
78
size_t memory_used; ///< Used cache size.
79
Map storage; ///< The hostnames/SSL_CTX * pairs
80
Queue lru_queue; ///< LRU cache index
84
/// Class for storing/manipulating LocalContextStorage per local listening address/port.
85
class GlobalContextStorage
88
friend class CertificateStorageAction;
90
GlobalContextStorage();
91
~GlobalContextStorage();
92
/// Create new SSL context storage for the local listening address/port.
93
void addLocalStorage(IpAddress const & address, size_t size_of_store);
94
/// Return the local storage for the given listening address/port.
95
LocalContextStorage & getLocalStorage(IpAddress const & address);
96
/// When reconfigring should be called this method.
97
void reconfigureStart();
99
/// Called by getLocalStorage method
100
void reconfigureFinish();
101
bool reconfiguring; ///< True if system reconfiguring now.
102
/// Storage used on configure or reconfigure.
103
std::map<IpAddress, size_t> configureStorage;
104
/// Map for storing all local ip address and their local storages.
105
std::map<IpAddress, LocalContextStorage *> storage;
108
/// Global cache for store all SSL server certificates.
109
extern GlobalContextStorage TheGlobalContextStorage;
113
#endif // SQUID_SSL_CONTEXT_STORAGE_H