PeerOptions.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
70 public:
74 
78 
80 
82  long parsedFlags = 0;
83 
84  std::list<Security::KeyData> certs;
85  std::list<SBuf> caFiles;
87 
88 protected:
89  template<typename T>
91 #if USE_OPENSSL
92  return ContextPointer(ctx, [](SSL_CTX *p) {
93  debugs(83, 5, "SSL_free ctx=" << (void*)p);
94  SSL_CTX_free(p);
95  });
96 #elif USE_GNUTLS
97  return Security::ContextPointer(ctx, [](gnutls_certificate_credentials_t p) {
98  debugs(83, 5, "gnutls_certificate_free_credentials ctx=" << (void*)p);
99  gnutls_certificate_free_credentials(p);
100  });
101 #else
102  assert(!ctx);
103  return Security::ContextPointer();
104 #endif
105  }
106 
107  int sslVersion = 0;
108 
110  struct flags_ {
112  flags_(const flags_ &) = default;
113  flags_ &operator =(const flags_ &) = default;
114 
117 
119  bool tlsNpn;
120  } flags;
121 
122 public:
124  bool encryptTransport = false;
125 };
126 
129 
130 } // namespace Security
131 
132 // parse the tls_outgoing_options directive
134 #define free_securePeerOptions(x) Security::ProxyOutgoingConfig.clear()
135 #define dump_securePeerOptions(e,n,x) do { (e)->appendf(n); (x).dumpCfg((e),""); (e)->append("\n",1); } while(false)
136 
137 #endif /* SQUID_SRC_SECURITY_PEEROPTIONS_H */
138 
#define assert(EX)
Definition: assert.h:17
virtual void clear()
reset the configuration details to default
Definition: PeerOptions.h:36
Definition: SBuf.h:87
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:81
bool encryptTransport
whether transport encryption (TLS/SSL) is to be used on connections to the peer
Definition: PeerOptions.h:124
Security::CertRevokeList parsedCrl
CRL to use when verifying the remote end certificate.
Definition: PeerOptions.h:86
YesNoNone tlsDefaultCa
whether to use the system default Trusted CA when verifying the remote end certificate ...
Definition: PeerOptions.h:116
SBuf sslOptions
library-specific options string
Definition: PeerOptions.h:71
long ParsedOptions
Definition: forward.h:154
virtual void dumpCfg(Packable *, const char *pfx) const
output squid.conf syntax with 'pfx' 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:119
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:110
virtual ~PeerOptions()
Definition: PeerOptions.h:30
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
#define true
Definition: GnuRegex.c:234
std::list< Security::CrlPointer > CertRevokeList
Definition: forward.h:107
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
void parse_securePeerOptions(Security::PeerOptions *)
Definition: PeerOptions.cc:735
SBuf crlFile
path of file containing Certificate Revoke List
Definition: PeerOptions.h:73
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:76
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:79
SBuf caDir
path of directory containing a set of trusted Certificate Authorities
Definition: PeerOptions.h:72
flags_ & operator=(const flags_ &)=default
std::list< SBuf > caFiles
paths of files containing trusted Certificate Authority
Definition: PeerOptions.h:85
void updateContextOptions(Security::ContextPointer &) const
Setup the library specific 'options=' 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:84
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
PeerOptions & operator=(const PeerOptions &)=default
Security::ContextPointer convertContextFromRawPtr(T ctx) const
Definition: PeerOptions.h:90
long parsedFlags
parsed value of sslFlags
Definition: PeerOptions.h:82
std::shared_ptr< SSL > SessionPointer
Definition: Session.h:41

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors