PeerOptions.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_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  virtual void clear() {*this = PeerOptions();}
37 
40 
43 
46 
49 
52 
55 
58 
61 
63  virtual void dumpCfg(Packable *, const char *pfx) const;
64 
65 private:
66  void parseOptions();
67  long parseFlags();
68  void loadCrlFile();
69  void loadKeysFile();
70 
71 public:
75 
79 
81 
83  long parsedFlags = 0;
84 
85  std::list<Security::KeyData> certs;
86  std::list<SBuf> caFiles;
88 
89 protected:
90  template<typename T>
92 #if USE_OPENSSL
93  return ContextPointer(ctx, [](SSL_CTX *p) {
94  debugs(83, 5, "SSL_free ctx=" << (void*)p);
95  SSL_CTX_free(p);
96  });
97 #elif USE_GNUTLS
98  return Security::ContextPointer(ctx, [](gnutls_certificate_credentials_t p) {
99  debugs(83, 5, "gnutls_certificate_free_credentials ctx=" << (void*)p);
100  gnutls_certificate_free_credentials(p);
101  });
102 #else
103  assert(!ctx);
104  return Security::ContextPointer();
105 #endif
106  }
107 
108  int sslVersion = 0;
109 
111  struct flags_ {
113  flags_(const flags_ &) = default;
114  flags_ &operator =(const flags_ &) = default;
115 
118 
120  bool tlsNpn;
121  } flags;
122 
123 public:
125  bool encryptTransport = false;
126 };
127 
130 
131 } // namespace Security
132 
133 // parse the tls_outgoing_options directive
135 #define free_securePeerOptions(x) Security::ProxyOutgoingConfig.clear()
136 #define dump_securePeerOptions(e,n,x) do { (e)->appendf(n); (x).dumpCfg((e),""); (e)->append("\n",1); } while(false)
137 
138 #endif /* SQUID_SRC_SECURITY_PEEROPTIONS_H */
139 
#define assert(EX)
Definition: assert.h:17
virtual void clear()
reset the configuration details to default
Definition: PeerOptions.h:36
Definition: SBuf.h:86
void updateContextCrl(Security::ContextPointer &)
setup the CRL details for the given context
Definition: PeerOptions.cc:685
Security::ParsedOptions parsedOptions
parsed value of sslOptions
Definition: PeerOptions.h:82
bool encryptTransport
whether transport encryption (TLS/SSL) is to be used on connections to the peer
Definition: PeerOptions.h:125
Security::CertRevokeList parsedCrl
CRL to use when verifying the remote end certificate.
Definition: PeerOptions.h:87
YesNoNone tlsDefaultCa
whether to use the system default Trusted CA when verifying the remote end certificate ...
Definition: PeerOptions.h:117
SBuf sslOptions
library-specific options string
Definition: PeerOptions.h:72
long ParsedOptions
Definition: forward.h:153
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:102
bool tlsNpn
whether to use the TLS NPN extension on these connections
Definition: PeerOptions.h:120
char * p
Definition: membanger.c:43
TLS squid.conf settings for a remote server peer.
Definition: PeerOptions.h:22
void updateContextNpn(Security::ContextPointer &)
setup the NPN extension details for the given context
Definition: PeerOptions.cc:618
void updateContextCa(Security::ContextPointer &)
setup the CA details for the given context
Definition: PeerOptions.cc:649
flags governing Squid internal TLS operations
Definition: PeerOptions.h:111
virtual ~PeerOptions()
Definition: PeerOptions.h:30
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
#define true
Definition: GnuRegex.c:234
std::list< Security::CrlPointer > CertRevokeList
Definition: forward.h:106
void updateSessionOptions(Security::SessionPointer &)
setup any library-specific options that can be set for the given session
Definition: PeerOptions.cc:710
PeerOptions ProxyOutgoingConfig
configuration options for DIRECT server access
Definition: PeerOptions.cc:22
SBuf crlFile
path of file containing Certificate Revoke List
Definition: PeerOptions.h:74
std::shared_ptr< SSL_CTX > ContextPointer
Definition: Context.h:28
virtual Security::ContextPointer createBlankContext() const
generate an unset security context object
Definition: PeerOptions.cc:245
Security::ContextPointer createClientContext(bool setOptions)
generate a security client-context from these configured options
Definition: PeerOptions.cc:279
SBuf sslFlags
flags defining what TLS operations Squid performs
Definition: PeerOptions.h:77
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:80
SBuf caDir
path of directory containing a set of trusted Certificate Authorities
Definition: PeerOptions.h:73
flags_ & operator=(const flags_ &)=default
std::list< SBuf > caFiles
paths of files containing trusted Certificate Authority
Definition: PeerOptions.h:86
void updateContextOptions(Security::ContextPointer &) const
Setup the library specific &#39;options=&#39; parameters for the given context.
Definition: PeerOptions.cc:597
struct Security::PeerOptions::flags_ flags
std::list< Security::KeyData > certs
details from the cert= and file= config parameters
Definition: PeerOptions.h:85
void updateTlsVersionLimits()
sync the context options with tls-min-version=N configuration
Definition: PeerOptions.cc:150
void parseOptions()
parsed value of sslOptions
Definition: PeerOptions.cc:436
void parse_securePeerOptions(Security::PeerOptions *opt)
Definition: PeerOptions.cc:735
PeerOptions & operator=(const PeerOptions &)=default
Security::ContextPointer convertContextFromRawPtr(T ctx) const
Definition: PeerOptions.h:91
long parsedFlags
parsed value of sslFlags
Definition: PeerOptions.h:83
std::shared_ptr< SSL > SessionPointer
Definition: Session.h:41

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors