]> git.ipfire.org Git - thirdparty/squid.git/blob - src/security/PeerOptions.h
merge from trunk r14590
[thirdparty/squid.git] / src / security / PeerOptions.h
1 /*
2 * Copyright (C) 1996-2016 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
21 /// TLS squid.conf settings for a remote server peer
22 class PeerOptions
23 {
24 public:
25 PeerOptions() : parsedOptions(0), parsedFlags(0), sslVersion(0), encryptTransport(false) {}
26 PeerOptions(const PeerOptions &);
27 virtual ~PeerOptions() = default;
28
29 /// parse a TLS squid.conf option
30 virtual void parse(const char *);
31
32 /// reset the configuration details to default
33 virtual void clear() {*this = PeerOptions();}
34
35 /// generate an unset security context object
36 virtual Security::ContextPtr createBlankContext() const;
37
38 /// generate a security client-context from these configured options
39 Security::ContextPtr createClientContext(bool setOptions);
40
41 /// sync the context options with tls-min-version=N configuration
42 void updateTlsVersionLimits();
43
44 /// setup the NPN extension details for the given context
45 void updateContextNpn(Security::ContextPtr &);
46
47 /// setup the CA details for the given context
48 void updateContextCa(Security::ContextPtr &);
49
50 /// setup the CRL details for the given context
51 void updateContextCrl(Security::ContextPtr &);
52
53 /// output squid.conf syntax with 'pfx' prefix on parameters for the stored settings
54 virtual void dumpCfg(Packable *, const char *pfx) const;
55
56 private:
57 long parseOptions();
58 long parseFlags();
59 void loadCrlFile();
60
61 public:
62 SBuf sslOptions; ///< library-specific options string
63 SBuf caDir; ///< path of directory containing a set of trusted Certificate Authorities
64 SBuf crlFile; ///< path of file containing Certificate Revoke List
65
66 SBuf sslCipher;
67 SBuf sslFlags; ///< flags defining what TLS operations Squid performs
68 SBuf sslDomain;
69
70 SBuf tlsMinVersion; ///< version label for minimum TLS version to permit
71
72 long parsedOptions; ///< parsed value of sslOptions
73 long parsedFlags; ///< parsed value of sslFlags
74
75 std::list<Security::KeyData> certs; ///< details from the cert= and file= config parameters
76 std::list<SBuf> caFiles; ///< paths of files containing trusted Certificate Authority
77 Security::CertRevokeList parsedCrl; ///< CRL to use when verifying the remote end certificate
78
79 protected:
80 int sslVersion;
81
82 /// flags governing Squid internal TLS operations
83 struct flags_ {
84 flags_() : tlsDefaultCa(true), tlsNpn(true) {}
85
86 /// whether to use the system default Trusted CA when verifying the remote end certificate
87 YesNoNone tlsDefaultCa;
88
89 /// whether to use the TLS NPN extension on these connections
90 bool tlsNpn;
91 } flags;
92
93 public:
94 /// whether transport encryption (TLS/SSL) is to be used on connections to the peer
95 bool encryptTransport;
96 };
97
98 /// configuration options for DIRECT server access
99 extern PeerOptions ProxyOutgoingConfig;
100
101 } // namespace Security
102
103 // parse the tls_outgoing_options directive
104 void parse_securePeerOptions(Security::PeerOptions *);
105 #define free_securePeerOptions(x) Security::ProxyOutgoingConfig.clear()
106 #define dump_securePeerOptions(e,n,x) do { (e)->appendf(n); (x).dumpCfg((e),""); (e)->append("\n",1); } while(false)
107
108 #endif /* SQUID_SRC_SECURITY_PEEROPTIONS_H */
109