217 {
219
222 .username = "snodec",
223 .password = "pentium5",
224 .database = "snodec",
225 .port = 3306,
226 .socket = "/run/mysqld/mysqld.sock",
227 .flags = 0,
228 };
229
230
231
232
233
234
235
237
238 {
240
241 legacyApp.use(
router(db));
242
244 switch (state) {
246 VLOG(1) << "legacy-testregex: listening on '" << socketAddress.toString() << "'";
247 break;
249 VLOG(1) << "legacy-testregex: disabled";
250 break;
252 VLOG(1) << "legacy-testregex: error occurred";
253 break;
255 VLOG(1) << "legacy-testregex: fatal error occurred";
256 break;
257 }
258 });
259
261 VLOG(1) << "OnConnect:";
262
263 VLOG(1) << "\tServer: " + socketConnection->getRemoteAddress().toString();
264 VLOG(1) << "\tClient: " + socketConnection->getLocalAddress().toString();
265 });
266
268 VLOG(1) << "OnDisconnect:";
269
270 VLOG(1) << "\tServer: " + socketConnection->getRemoteAddress().toString();
271 VLOG(1) << "\tClient: " + socketConnection->getLocalAddress().toString();
272 });
273
275
276 tlsApp.use(legacyApp);
277
279 switch (state) {
281 VLOG(1) << "tls-testregex: listening on '" << socketAddress.toString() << "'";
282 break;
284 VLOG(1) << "tls-testregex: disabled";
285 break;
287 VLOG(1) << "tls-testregex: error occurred";
288 break;
290 VLOG(1) << "tls-testregex: fatal error occurred";
291 break;
292 }
293 });
294
296 VLOG(1) << "OnConnect:";
297
298 VLOG(1) << "\tServer: " + socketConnection->getRemoteAddress().toString();
299 VLOG(1) << "\tClient: " + socketConnection->getLocalAddress().toString();
300 });
301
303 VLOG(1) << "OnConnected:";
304
305 X509* client_cert = SSL_get_peer_certificate(socketConnection->getSSL());
306
307 if (client_cert != nullptr) {
308 const long verifyErr = SSL_get_verify_result(socketConnection->getSSL());
309
310 VLOG(1) << "\tClient certificate: " + std::string(X509_verify_cert_error_string(verifyErr));
311
312 char* str = X509_NAME_oneline(X509_get_subject_name(client_cert), nullptr, 0);
313 VLOG(1) << "\t Subject: " + std::string(str);
314 OPENSSL_free(str);
315
316 str = X509_NAME_oneline(X509_get_issuer_name(client_cert), nullptr, 0);
317 VLOG(1) << "\t Issuer: " + std::string(str);
318 OPENSSL_free(str);
319
320
321
322 GENERAL_NAMES* subjectAltNames =
323 static_cast<GENERAL_NAMES*>(X509_get_ext_d2i(client_cert, NID_subject_alt_name, nullptr, nullptr));
324#ifdef __GNUC__
325#pragma GCC diagnostic push
326#ifdef __has_warning
327#if __has_warning("-Wused-but-marked-unused")
328#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
329#endif
330#endif
331#endif
332 const int32_t altNameCount = sk_GENERAL_NAME_num(subjectAltNames);
333#ifdef __GNUC_
334#pragma GCC diagnostic pop
335#endif
336 VLOG(1) << "\t Subject alternative name count: " << altNameCount;
337 for (int32_t i = 0; i < altNameCount; ++i) {
338#ifdef __GNUC__
339#pragma GCC diagnostic push
340#ifdef __has_warning
341#if __has_warning("-Wused-but-marked-unused")
342#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
343#endif
344#endif
345#endif
346 GENERAL_NAME* generalName = sk_GENERAL_NAME_value(subjectAltNames, i);
347#ifdef __GNUC_
348#pragma GCC diagnostic pop
349#endif
350 if (generalName->type == GEN_URI) {
351 const std::string subjectAltName =
352 std::string(reinterpret_cast<const char*>(ASN1_STRING_get0_data(generalName->d.uniformResourceIdentifier)),
353 static_cast<std::size_t>(ASN1_STRING_length(generalName->d.uniformResourceIdentifier)));
354 VLOG(1) << "\t SAN (URI): '" + subjectAltName;
355 } else if (generalName->type == GEN_DNS) {
356 const std::string subjectAltName =
357 std::string(reinterpret_cast<const char*>(ASN1_STRING_get0_data(generalName->d.dNSName)),
358 static_cast<std::size_t>(ASN1_STRING_length(generalName->d.dNSName)));
359 VLOG(1) << "\t SAN (DNS): '" + subjectAltName;
360 } else {
361 VLOG(1) << "\t SAN (Type): '" + std::to_string(generalName->type);
362 }
363 }
364#ifdef __GNUC__
365#pragma GCC diagnostic push
366#ifdef __has_warning
367#if __has_warning("-Wused-but-marked-unused")
368#pragma GCC diagnostic ignored "-Wused-but-marked-unused"
369#endif
370#endif
371#endif
372 sk_GENERAL_NAME_pop_free(subjectAltNames, GENERAL_NAME_free);
373#ifdef __GNUC_
374#pragma GCC diagnostic pop
375#endif
376 X509_free(client_cert);
377 } else {
378 VLOG(1) << "\tClient certificate: no certificate";
379 }
380 });
381
383 VLOG(1) << "OnDisconnect:";
384
385 VLOG(1) << "\tServer: " + socketConnection->getRemoteAddress().toString();
386 VLOG(1) << "\tClient: " + socketConnection->getLocalAddress().toString();
387 });
388 }
389
391}
static constexpr int DISABLED
static constexpr int ERROR
static constexpr int FATAL
typename Server::SocketConnection SocketConnection
typename Server::SocketAddress SocketAddress
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
Router router(database::mariadb::MariaDBClient &db)