Session.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 #include "compat/openssl.h"
20 #if HAVE_OPENSSL_SSL_H
21 #include <openssl/ssl.h>
22 #endif
23 #endif
24 
25 #if USE_GNUTLS
26 #if HAVE_GNUTLS_GNUTLS_H
27 #include <gnutls/gnutls.h>
28 #endif
29 #endif
30 
31 namespace Security {
32 
35 bool CreateClientSession(const Security::ContextPointer &, const Comm::ConnectionPointer &, const char *squidCtx);
36 
39 bool CreateServerSession(const Security::ContextPointer &, const Comm::ConnectionPointer &, const char *squidCtx);
40 
41 #if USE_OPENSSL
42 typedef std::shared_ptr<SSL> SessionPointer;
43 
44 typedef std::unique_ptr<SSL_SESSION, HardFun<void, SSL_SESSION*, &SSL_SESSION_free>> SessionStatePointer;
45 
46 #elif USE_GNUTLS
47 typedef std::shared_ptr<struct gnutls_session_int> SessionPointer;
48 
49 // wrapper function to get around gnutls_free being a typedef
50 inline void squid_gnutls_free(void *d) {gnutls_free(d);}
51 typedef std::unique_ptr<gnutls_datum_t, HardFun<void, void*, &Security::squid_gnutls_free>> SessionStatePointer;
52 
53 #else
54 typedef std::shared_ptr<void> SessionPointer;
55 
56 typedef std::unique_ptr<int> SessionStatePointer;
57 
58 #endif
59 
62 
65 
76 
80 
81 #if USE_OPENSSL
82 // TODO: remove from public API. It is only public because of Security::ServerOptions::updateContextConfig
85 
89 {
90  auto *ctx = SSL_get_SSL_CTX(s.get());
91  return Security::ContextPointer(ctx, [](SSL_CTX *) {/* nothing to unlock/free */});
92 }
93 
98 #endif
99 
100 } // namespace Security
101 
102 #endif /* SQUID_SRC_SECURITY_SESSION_H */
103 
std::unique_ptr< SSL_SESSION, HardFun< void, SSL_SESSION *,&SSL_SESSION_free > > SessionStatePointer
Definition: Session.h:44
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:88
std::shared_ptr< SSL_CTX > ContextPointer
Definition: Context.h:29
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:373
std::shared_ptr< SSL > SessionPointer
Definition: Session.h:42

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors