SNode.C
Loading...
Searching...
No Matches
ConfigTls.cpp
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "net/config/ConfigTls.h"
21
22#include "net/config/ConfigSection.hpp"
23
24#ifndef DOXYGEN_SHOULD_SKIP_THIS
25
26#endif /* DOXYGEN_SHOULD_SKIP_THIS */
27
28namespace net::config {
29
31 : ConfigSection(instance, "tls", "Configuration of SSL/TLS behavior") {
32 certOpt = addOption( //
33 "--cert",
34 "Certificate chain file",
35 "filename:PEM-FILE",
36 "");
37
39 "--cert-key",
40 "Certificate key file",
41 "filename:PEM-FILE",
42 "");
43
45 "--cert-key-password",
46 "Password for the certificate key file",
47 "password",
48 "",
50
52 "--ca-cert",
53 "CA-certificate file",
54 "filename:PEM-FILE",
55 "");
56
58 "--ca-cert-dir",
59 "CA-certificate directory",
60 "directory:PEM-CONTAINER-DIR",
61 "");
62
64 "--ca-cert-use-default-dir{true}",
65 "Use default CA-certificate directory",
66 "bool",
67 "false",
68 CLI::IsMember({"true", "false"}));
69
71 "--ca-cert-accept-unknown{true}",
72 "Accept unknown certificates (unsecure)",
73 "bool",
74 "false",
75 CLI::IsMember({"true", "false"}));
76
78 "--cipher-list",
79 "Cipher list (OpenSSL syntax)",
80 "cipher_list",
81 "",
82 CLI::TypeValidator<std::string>("CIPHER"));
83
85 "--ssl-options",
86 "OR combined SSL/TLS options (OpenSSL values)",
87 "options",
88 0,
90
92 "--init-timeout",
93 "SSL/TLS initialization timeout in seconds",
94 "timeout",
97
99 "--shutdown-timeout",
100 "SSL/TLS shutdown timeout in seconds",
101 "timeout",
104
106 "--no-close-notify-is-eof{true}",
107 "Do not interpret a SSL/TLS close_notify alert as EOF",
108 "bool",
109 "false",
110 CLI::IsMember({"true", "false"}));
111 }
112
114 certOpt //
116 ->clear();
117
118 return *this;
119 }
120
122 return certOpt->as<std::string>();
123 }
124
126 certKeyOpt //
128 ->clear();
129
130 return *this;
131 }
132
134 return certKeyOpt->as<std::string>();
135 }
136
144
148
150 caCertOpt //
152 ->clear();
153
154 return *this;
155 }
156
158 return caCertOpt->as<std::string>();
159 }
160
162 caCertDirOpt //
164 ->clear();
165
166 return *this;
167 }
168
170 return caCertDirOpt->as<std::string>();
171 }
172
175 ->default_val(set ? "true" : "false")
176 ->clear();
177
178 return *this;
179 }
180
182 return caCertUseDefaultDirOpt->as<bool>();
183 }
184
187 ->default_val(set ? "true" : "false")
188 ->clear();
189
190 return *this;
191 }
192
194 return caCertAcceptUnknownOpt->as<bool>();
195 }
196
200 ->clear();
201
202 return *this;
203 }
204
206 return cipherListOpt->as<std::string>();
207 }
208
212 ->clear();
213
214 return *this;
215 }
216
220
223 ->default_val(closeNotifyIsEOF ? "true" : "false")
224 ->clear();
225 return *this;
226 }
227
229 return noCloseNotifyIsEOFOpt->as<bool>();
230 }
231
235 ->clear();
236
237 return *this;
238 }
239
243
251
253 return shutdownTimeoutOpt //
254 ->as<utils::Timeval>();
255 }
256
257} // namespace net::config