Session.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 
37 class PeerOptions;
38 
42 
43 #if USE_OPENSSL
44 typedef std::shared_ptr<SSL> SessionPointer;
45 
46 typedef std::unique_ptr<SSL_SESSION, HardFun<void, SSL_SESSION*, &SSL_SESSION_free>> SessionStatePointer;
47 
48 #elif USE_GNUTLS
49 typedef std::shared_ptr<struct gnutls_session_int> SessionPointer;
50 
51 // wrapper function to get around gnutls_free being a typedef
52 inline void squid_gnutls_free(void *d) {gnutls_free(d);}
53 typedef std::unique_ptr<gnutls_datum_t, HardFun<void, void*, &Security::squid_gnutls_free>> SessionStatePointer;
54 
55 #else
56 typedef std::shared_ptr<void> SessionPointer;
57 
58 typedef std::unique_ptr<int> SessionStatePointer;
59 
60 #endif
61 
64 
67 
78 
82 
83 #if USE_OPENSSL
84 // TODO: remove from public API. It is only public because of Security::ServerOptions::updateContextConfig
87 
91 {
92  auto *ctx = SSL_get_SSL_CTX(s.get());
93  return Security::ContextPointer(ctx, [](SSL_CTX *) {/* nothing to unlock/free */});
94 }
95 
100 #endif
101 
102 } // namespace Security
103 
104 #endif /* SQUID_SRC_SECURITY_SESSION_H */
105 
std::unique_ptr< SSL_SESSION, HardFun< void, SSL_SESSION *, &SSL_SESSION_free > > SessionStatePointer
Definition: Session.h:46
bool CreateServerSession(const Security::ContextPointer &, const Comm::ConnectionPointer &, Security::PeerOptions &, const char *squidCtx)
Definition: Session.cc:194
void SessionSendGoodbye(const Security::SessionPointer &)
send the shutdown/bye notice for an active TLS session.
Definition: Session.cc:200
bool SessionIsResumed(const Security::SessionPointer &)
whether the session is a resumed one
Definition: Session.cc:213
TLS squid.conf settings for a remote server peer.
Definition: PeerOptions.h:22
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:184
Security::ContextPointer GetFrom(Security::SessionPointer &s)
Helper function to retrieve a (non-locked) ContextPointer from a SessionPointer.
Definition: Session.h:90
std::shared_ptr< SSL_CTX > ContextPointer
Definition: Context.h:29
Network/connection security abstraction layer.
Definition: Connection.h:31
void SetSessionResumeData(const Security::SessionPointer &, const Security::SessionStatePointer &)
Definition: Session.cc:247
void MaybeGetSessionResumeData(const Security::SessionPointer &, Security::SessionStatePointer &data)
Definition: Session.cc:226
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:376
std::shared_ptr< SSL > SessionPointer
Definition: Session.h:44

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors