2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "net/config/ConfigTlsServer.h"
50#ifndef DOXYGEN_SHOULD_SKIP_THIS
62 "Server Name Indication (SNI) Certificates:\n"
63 "sni = SNI of the virtual server\n"
65 " Cert -> value:PEM-FILE [\"\"]\n"
66 " CertKey -> value:PEM-FILE [\"\"]\n"
67 " CertKeyPassword -> value:TEXT [\"\"]\n"
68 " CaCert -> value:PEM-FILE [\"\"]\n"
69 " CaCertDir -> value:PEM-CONTAINER-DIR [\"\"]\n"
70 " CaCertUseDefaultDir -> value:BOOLEAN [false]\n"
71 " CipherList -> value:CIPHER [\"\"]\n"
72 " SslOptions -> value:UINT [0]\n"
74 "sni <key> value [<key> value] ... [%% sni <key> value [<key> value] ...]",
75 CLI::TypeValidator<std::string>()
);
77 sniCertsOpt->default_function([
this]() -> std::string {
78 std::string defaultValue;
81 defaultValue += (!defaultValue.empty() ?
"%% " :
"") + domain +
" ";
83 for (
const auto& [key, value] : sniCertConf) {
84 defaultValue += key +
" ";
87 defaultValue += std::get<std::string>(value) +
" ";
88 }
else if (key ==
"CertKey") {
89 defaultValue += std::get<std::string>(value) +
" ";
90 }
else if (key ==
"CertKeyPassword") {
91 defaultValue += std::get<std::string>(value) +
" ";
92 }
else if (key ==
"CaCert") {
93 defaultValue += std::get<std::string>(value) +
" ";
94 }
else if (key ==
"CaCertDir") {
95 defaultValue += std::get<std::string>(value) +
" ";
96 }
else if (key ==
"CaCertUseDefaultDir") {
97 defaultValue += std::get<
bool>(value) ?
"true " :
"false ";
98 }
else if (key ==
"CipherList") {
99 defaultValue += std::get<std::string>(value) +
" ";
100 }
else if (key ==
"SslOptions") {
101 defaultValue += std::to_string(std::get<ssl_option_t>(value)) +
" ";
106 defaultValue.pop_back();
108 return "[" + defaultValue +
"]";
113 "Force using of the Server Name Indication",
116 CLI::IsMember({
"true",
"false"})
);
120 if (domain.empty()) {
126 for (
auto& [key, value] : sniMap) {
129 key !=
"CertKeyPassword" &&
131 key !=
"CaCertDir" &&
132 key !=
"CaCertUseDefaultDir" &&
133 key !=
"CipherList" &&
134 key !=
"SslOptions") {
157 const std::map<std::string, std::map<std::string, std::variant<std::string,
bool, ssl_option_t>>>& sniCerts) {
165 const std::map<std::string, std::variant<std::string,
bool, ssl_option_t>>& sniCert) {
172 const std::map<std::string, std::map<std::string, std::variant<std::string,
bool, ssl_option_t>>>&
std::map< std::string, std::map< std::string, std::variant< std::string, bool, ssl_option_t > > > configuredSniCerts
ConfigTlsServer & addSniCerts(const std::map< std::string, std::map< std::string, std::variant< std::string, bool, ssl_option_t > > > &sniCerts)
ConfigTlsServer(ConfigInstance *instance)
ConfigTlsServer & setForceSni(bool forceSni=true)
const std::map< std::string, std::map< std::string, std::variant< std::string, bool, ssl_option_t > > > & getSniCerts() const
std::map< std::string, std::map< std::string, std::variant< std::string, bool, ssl_option_t > > > defaultSniCerts
CLI::Option * sniCertsOpt
CLI::Option * forceSniOpt
ConfigTlsServer & addSniCert(const std::string &domain, const std::map< std::string, std::variant< std::string, bool, ssl_option_t > > &sniCert)
~ConfigTlsServer() override
ConfigTls(ConfigInstance *instance, ConcretConfigTls section)
CLI::Option * addFlag(const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * setDefaultValue(CLI::Option *option, const ValueTypeT &value, bool clear=true) const
SubCommand * finalCallback(const std::function< void()> &finalCallback)
std::string getName() const
CLI::Option * addOptionVariable(const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator) const