]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
bde978a6 | 2 | * Copyright (C) 1996-2015 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
95d2589c CT |
9 | #ifndef SQUID_SSL_CONTEXT_STORAGE_H |
10 | #define SQUID_SSL_CONTEXT_STORAGE_H | |
11 | ||
cb4f4424 | 12 | #if USE_OPENSSL |
95d2589c | 13 | |
14798e73 | 14 | #include "base/LruMap.h" |
95d2589c | 15 | #include "CacheManager.h" |
c6983ec7 | 16 | #include "ip/Address.h" |
95d2589c CT |
17 | #include "mgr/Action.h" |
18 | #include "mgr/Command.h" | |
602d9612 | 19 | #include "SquidTime.h" |
14798e73 | 20 | #include "ssl/gadgets.h" |
074d6a40 | 21 | |
95d2589c | 22 | #include <list> |
074d6a40 | 23 | #include <map> |
cb4f4424 | 24 | #if HAVE_OPENSSL_SSL_H |
a011edee | 25 | #include <openssl/ssl.h> |
cb4f4424 | 26 | #endif |
a011edee | 27 | |
95d2589c CT |
28 | /// TODO: Replace on real size. |
29 | #define SSL_CTX_SIZE 1024 | |
30 | ||
31 | namespace Ssl | |
32 | { | |
33 | ||
34 | /** Reports cached SSL certificate stats to Cache Manager. | |
35 | * TODO: Use "Report" functions instead friend class. | |
36 | */ | |
37 | class CertificateStorageAction : public Mgr::Action | |
38 | { | |
39 | public: | |
40 | CertificateStorageAction(const Mgr::Command::Pointer &cmd); | |
41 | static Pointer Create(const Mgr::Command::Pointer &cmd); | |
42 | virtual void dump (StoreEntry *sentry); | |
43 | /** | |
44 | * We do not support aggregation of information across workers | |
45 | * TODO: aggregate these stats | |
46 | */ | |
47 | virtual bool aggregatable() const { return false; } | |
48 | }; | |
49 | ||
14798e73 | 50 | typedef LruMap<SSL_CTX_Pointer, SSL_CTX_SIZE> LocalContextStorage; |
95d2589c | 51 | |
95d2589c CT |
52 | /// Class for storing/manipulating LocalContextStorage per local listening address/port. |
53 | class GlobalContextStorage | |
54 | { | |
55 | friend class CertificateStorageAction; | |
56 | public: | |
57 | GlobalContextStorage(); | |
58 | ~GlobalContextStorage(); | |
59 | /// Create new SSL context storage for the local listening address/port. | |
60 | void addLocalStorage(Ip::Address const & address, size_t size_of_store); | |
61 | /// Return the local storage for the given listening address/port. | |
9873e378 | 62 | LocalContextStorage *getLocalStorage(Ip::Address const & address); |
95d2589c CT |
63 | /// When reconfigring should be called this method. |
64 | void reconfigureStart(); | |
65 | private: | |
66 | /// Called by getLocalStorage method | |
67 | void reconfigureFinish(); | |
68 | bool reconfiguring; ///< True if system reconfiguring now. | |
69 | /// Storage used on configure or reconfigure. | |
70 | std::map<Ip::Address, size_t> configureStorage; | |
71 | /// Map for storing all local ip address and their local storages. | |
72 | std::map<Ip::Address, LocalContextStorage *> storage; | |
73 | }; | |
74 | ||
75 | /// Global cache for store all SSL server certificates. | |
76 | extern GlobalContextStorage TheGlobalContextStorage; | |
77 | } //namespace Ssl | |
cb4f4424 | 78 | #endif // USE_OPENSSL |
95d2589c CT |
79 | |
80 | #endif // SQUID_SSL_CONTEXT_STORAGE_H | |
f53969cc | 81 |