PeerOptions.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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_PEEROPTIONS_H
10#define SQUID_SRC_SECURITY_PEEROPTIONS_H
11
12#include "base/YesNoNone.h"
13#include "ConfigParser.h"
14#include "security/Context.h"
15#include "security/forward.h"
16#include "security/KeyData.h"
17#include "security/Session.h"
18
19class Packable;
20
21namespace Security
22{
23
26{
27public:
29 PeerOptions(const PeerOptions &) = default;
30 PeerOptions &operator =(const PeerOptions &) = default;
31 PeerOptions(PeerOptions &&) = default;
33 virtual ~PeerOptions() {}
34
36 virtual void parse(const char *);
37
39 void parseOptions();
40
42 virtual void clear() {*this = PeerOptions();}
43
46
49
52
55
58
61
64
67
70
72 virtual void dumpCfg(std::ostream &, const char *pfx) const;
73
74private:
76 void loadCrlFile();
78
79public:
83
87
89
90private:
94
98
100 bool optsReparse = true;
101
102public:
104
105 std::list<Security::KeyData> certs;
106 std::list<SBuf> caFiles;
108
109protected:
110 template<typename T>
112#if USE_OPENSSL
113 debugs(83, 5, "SSL_CTX construct, this=" << (void*)ctx);
114 return ContextPointer(ctx, [](SSL_CTX *p) {
115 debugs(83, 5, "SSL_CTX destruct, this=" << (void*)p);
116 SSL_CTX_free(p);
117 });
118#elif USE_GNUTLS
119 debugs(83, 5, "gnutls_certificate_credentials construct, this=" << (void*)ctx);
120 return Security::ContextPointer(ctx, [](gnutls_certificate_credentials_t p) {
121 debugs(83, 5, "gnutls_certificate_credentials destruct, this=" << (void*)p);
122 gnutls_certificate_free_credentials(p);
123 });
124#else
125 assert(!ctx);
127#endif
128 }
129
130 int sslVersion = 0;
131
133 struct flags_ {
134 flags_() : tlsDefaultCa(true), tlsNpn(true) {}
135 flags_(const flags_ &) = default;
136 flags_ &operator =(const flags_ &) = default;
137
140
142 bool tlsNpn;
144
145public:
147 bool encryptTransport = false;
148};
149
152
153} // namespace Security
154
155// parse the tls_outgoing_options directive
157#define free_securePeerOptions(x) Security::ProxyOutgoingConfig.clear()
158#define dump_securePeerOptions(e,n,x) do { PackableStream os_(*(e)); os_ << n; (x).dumpCfg(os_,""); os_ << '\n'; } while (false)
159
160#endif /* SQUID_SRC_SECURITY_PEEROPTIONS_H */
161
void parse_securePeerOptions(Security::PeerOptions *)
Definition: PeerOptions.cc:805
#define assert(EX)
Definition: assert.h:17
Definition: SBuf.h:94
TLS squid.conf settings for a remote server peer.
Definition: PeerOptions.h:26
void updateContextCrl(Security::ContextPointer &)
setup the CRL details for the given context
Definition: PeerOptions.cc:727
std::list< SBuf > caFiles
paths of files containing trusted Certificate Authority
Definition: PeerOptions.h:106
ParsedPortFlags parseFlags()
Definition: PeerOptions.cc:549
SBuf crlFile
path of file containing Certificate Revoke List
Definition: PeerOptions.h:82
PeerOptions(const PeerOptions &)=default
Security::ContextPointer createClientContext(bool setOptions)
generate a security client-context from these configured options
Definition: PeerOptions.cc:271
Security::CertRevokeList parsedCrl
CRL to use when verifying the remote end certificate.
Definition: PeerOptions.h:107
ParsedPortFlags parsedFlags
parsed value of sslFlags
Definition: PeerOptions.h:103
virtual void parse(const char *)
parse a TLS squid.conf option
Definition: PeerOptions.cc:33
virtual ~PeerOptions()
Definition: PeerOptions.h:33
virtual void clear()
reset the configuration details to default
Definition: PeerOptions.h:42
bool optsReparse
whether parsedOptions content needs to be regenerated
Definition: PeerOptions.h:100
SBuf sslFlags
flags defining what TLS operations Squid performs
Definition: PeerOptions.h:85
Security::ContextPointer convertContextFromRawPtr(T ctx) const
Definition: PeerOptions.h:111
SBuf sslOptions
library-specific options string
Definition: PeerOptions.h:80
PeerOptions & operator=(const PeerOptions &)=default
Security::ParsedOptions parsedOptions
Definition: PeerOptions.h:97
struct Security::PeerOptions::flags_ flags
void updateContextCa(Security::ContextPointer &)
setup the CA details for the given context
Definition: PeerOptions.cc:691
void updateContextOptions(Security::ContextPointer &)
Setup the library specific 'options=' parameters for the given context.
Definition: PeerOptions.cc:634
SBuf caDir
path of directory containing a set of trusted Certificate Authorities
Definition: PeerOptions.h:81
void updateTlsVersionLimits()
sync the context options with tls-min-version=N configuration
Definition: PeerOptions.cc:153
virtual void dumpCfg(std::ostream &, const char *pfx) const
output squid.conf syntax with 'pfx' prefix on parameters for the stored settings
Definition: PeerOptions.cc:105
PeerOptions(PeerOptions &&)=default
SBuf tlsMinVersion
version label for minimum TLS version to permit
Definition: PeerOptions.h:88
void updateContextTrust(Security::ContextPointer &)
decide which CAs to trust
Definition: PeerOptions.cc:754
void parseOptions()
parse and verify the [tls-]options= string in sslOptions
Definition: PeerOptions.cc:442
void updateContextNpn(Security::ContextPointer &)
setup the NPN extension details for the given context
Definition: PeerOptions.cc:659
std::list< Security::KeyData > certs
details from the cert= and file= config parameters
Definition: PeerOptions.h:105
virtual Security::ContextPointer createBlankContext() const
generate an unset security context object
Definition: PeerOptions.cc:241
void updateSessionOptions(Security::SessionPointer &)
setup any library-specific options that can be set for the given session
Definition: PeerOptions.cc:774
bool encryptTransport
whether transport encryption (TLS/SSL) is to be used on connections to the peer
Definition: PeerOptions.h:147
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194
Network/connection security abstraction layer.
Definition: Connection.h:34
std::shared_ptr< SSL_CTX > ContextPointer
Definition: Context.h:29
uint64_t ParsedOptions
Definition: forward.h:192
std::shared_ptr< SSL > SessionPointer
Definition: Session.h:49
long ParsedPortFlags
Definition: forward.h:202
PeerOptions ProxyOutgoingConfig
configuration options for DIRECT server access
Definition: PeerOptions.cc:24
std::list< Security::CrlPointer > CertRevokeList
Definition: forward.h:105
flags governing Squid internal TLS operations
Definition: PeerOptions.h:133
YesNoNone tlsDefaultCa
whether to use the system default Trusted CA when verifying the remote end certificate
Definition: PeerOptions.h:139
flags_(const flags_ &)=default
flags_ & operator=(const flags_ &)=default
bool tlsNpn
whether to use the TLS NPN extension on these connections
Definition: PeerOptions.h:142

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors