Session.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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 
9 #ifndef SQUID_SRC_SECURITY_SESSION_H
10 #define SQUID_SRC_SECURITY_SESSION_H
11 
12 #include "base/HardFun.h"
13 #include "comm/forward.h"
15 
16 #include <memory>
17 
18 #if USE_OPENSSL
19 #if HAVE_OPENSSL_SSL_H
20 #include <openssl/ssl.h>
21 #endif
22 #endif
23 
24 #if USE_GNUTLS
25 #if HAVE_GNUTLS_GNUTLS_H
26 #include <gnutls/gnutls.h>
27 #endif
28 #endif
29 
30 namespace Security {
31 
34 bool CreateClientSession(const Security::ContextPointer &, const Comm::ConnectionPointer &, const char *squidCtx);
35 
38 bool CreateServerSession(const Security::ContextPointer &, const Comm::ConnectionPointer &, const char *squidCtx);
39 
40 #if USE_OPENSSL
41 typedef std::shared_ptr<SSL> SessionPointer;
42 
43 typedef std::unique_ptr<SSL_SESSION, HardFun<void, SSL_SESSION*, &SSL_SESSION_free>> SessionStatePointer;
44 
45 #elif USE_GNUTLS
46 typedef std::shared_ptr<struct gnutls_session_int> SessionPointer;
47 
48 // wrapper function to get around gnutls_free being a typedef
49 inline void squid_gnutls_free(void *d) {gnutls_free(d);}
50 typedef std::unique_ptr<gnutls_datum_t, HardFun<void, void*, &Security::squid_gnutls_free>> SessionStatePointer;
51 
52 #else
53 typedef std::shared_ptr<void> SessionPointer;
54 
55 typedef std::unique_ptr<int> SessionStatePointer;
56 
57 #endif
58 
61 
64 
75 
79 
80 #if USE_OPENSSL
81 // TODO: remove from public API. It is only public because of Security::ServerOptions::updateContextConfig
84 
88 {
89  auto *ctx = SSL_get_SSL_CTX(s.get());
90  return Security::ContextPointer(ctx, [](SSL_CTX *) {/* nothing to unlock/free */});
91 }
92 
97 #endif
98 
99 } // namespace Security
100 
101 #endif /* SQUID_SRC_SECURITY_SESSION_H */
102 
std::unique_ptr< SSL_SESSION, HardFun< void, SSL_SESSION *,&SSL_SESSION_free > > SessionStatePointer
Definition: Session.h:43
void SessionSendGoodbye(const Security::SessionPointer &)
send the shutdown/bye notice for an active TLS session.
Definition: Session.cc:197
bool SessionIsResumed(const Security::SessionPointer &)
whether the session is a resumed one
Definition: Session.cc:210
bool CreateServerSession(const Security::ContextPointer &, const Comm::ConnectionPointer &, const char *squidCtx)
Definition: Session.cc:191
void const char HLPCB void * data
Definition: stub_helper.cc:16
bool CreateClientSession(const Security::ContextPointer &, const Comm::ConnectionPointer &, const char *squidCtx)
Definition: Session.cc:185
Security::ContextPointer GetFrom(Security::SessionPointer &s)
Helper function to retrieve a (non-locked) ContextPointer from a SessionPointer.
Definition: Session.h:87
std::shared_ptr< SSL_CTX > ContextPointer
Definition: Context.h:28
void SetSessionResumeData(const Security::SessionPointer &, const Security::SessionStatePointer &)
Definition: Session.cc:244
void MaybeGetSessionResumeData(const Security::SessionPointer &, Security::SessionStatePointer &data)
Definition: Session.cc:223
Security::SessionPointer NewSessionObject(const Security::ContextPointer &)
Definition: Session.cc:97
void SetSessionCacheCallbacks(Security::ContextPointer &)
Setup the given TLS context with callbacks used to manage the session cache.
Definition: Session.cc:378
std::shared_ptr< SSL > SessionPointer
Definition: Session.h:41

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors