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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors