#include "dolog.hh"
#include "iputils.hh"
#include "lock.hh"
+#include "logging.hh"
#include "tcpiohandler.hh"
const bool TCPIOHandler::s_disableConnectForUnitTests = false;
auto [ctx, warnings] = libssl_init_server_context(tlsConfig);
for (const auto& warning : warnings) {
+#if defined(DNSDIST)
+ SLOG(warnlog("%s", warning),
+ dnsdist::logging::getTopLogger()->info(Logr::Warning, warning));
+#else /* DNSDIST */
warnlog("%s", warning);
+#endif /* DNSDIST */
}
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer): it cannot be initialized before calling libssl_init_server_context()
d_ocspResponses = std::move(ctx.d_ocspResponses);
d_socket = socket;
if (!d_conn) {
- vinfolog("Error creating TLS object");
+ VERBOSESLOG(infolog("Error creating TLS object"),
+ dnsdist::logging::getTopLogger()->info(Logr::Info, "Error creating server-side TLS object"));
if (shouldDoVerboseLogging()) {
ERR_print_errors_fp(stderr);
}
d_socket = socket;
if (!d_conn) {
- vinfolog("Error creating TLS object");
+ VERBOSESLOG(infolog("Error creating TLS object"),
+ dnsdist::logging::getTopLogger()->info(Logr::Info, "Error creating client-side TLS object"));
if (shouldDoVerboseLogging()) {
ERR_print_errors_fp(stderr);
}
SSL_CTX_set_verify(d_tlsCtx.get(), SSL_VERIFY_PEER, nullptr);
#if (OPENSSL_VERSION_NUMBER < 0x10002000L)
+#if defined(DNSDIST)
+ SLOG(warnlog("TLS hostname validation requested but not supported for OpenSSL < 1.0.2"),
+ dnsdist::logging::getTopLogger()->info(Logr::Warning, "TLS hostname validation requested but not supported for OpenSSL < 1.0.2"));
+#else /* DNSDIST */
warnlog("TLS hostname validation requested but not supported for OpenSSL < 1.0.2");
-#endif
+#endif /* DNSDIST */
+#endif /* OPENSSL_VERSION_NUMBER < 0x10002000L */
}
/* we need to set SSL_SESS_CACHE_CLIENT for the "new ticket" callback (below) to be called,
else if (res == GNUTLS_E_AGAIN) {
return IOState::NeedWrite;
}
- vinfolog("Warning, non-fatal error while writing to TLS connection: %s", gnutls_strerror(res));
+ VERBOSESLOG(infolog("Warning, non-fatal error while writing to TLS connection: %s", gnutls_strerror(res)),
+ dnsdist::logging::getTopLogger()->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
}
}
while (pos < toWrite);
else if (res == GNUTLS_E_AGAIN) {
return IOState::NeedRead;
}
- vinfolog("Warning, non-fatal error while writing to TLS connection: %s", gnutls_strerror(res));
+ VERBOSESLOG(infolog("Warning, non-fatal error while writing to TLS connection: %s", gnutls_strerror(res)),
+ dnsdist::logging::getTopLogger()->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
}
}
while (pos < toRead);
}
}
else {
- vinfolog("Non-fatal error while reading from TLS connection: %s", gnutls_strerror(res));
+ VERBOSESLOG(infolog("Non-fatal error while reading from TLS connection: %s", gnutls_strerror(res)),
+ dnsdist::logging::getTopLogger()->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while reading from TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
}
}
}
}
else {
- vinfolog("Non-fatal error while writing to TLS connection: %s", gnutls_strerror(res));
+ VERBOSESLOG(infolog("Non-fatal error while writing to TLS connection: %s", gnutls_strerror(res)),
+ dnsdist::logging::getTopLogger()->error(Logr::Info, gnutls_strerror(res), "Non-fatal error while writing to TLS connection", "tls.provider", Logging::Loggable("GnuTLS")));
}
}
}
for (const auto& file : frontend.d_tlsConfig.d_ocspFiles) {
rc = gnutls_certificate_set_ocsp_status_request_file(d_creds.get(), file.c_str(), count);
if (rc != GNUTLS_E_SUCCESS) {
+#if defined(DNSDIST)
+ SLOG(warnlog("Error loading OCSP response from file '%s' for certificate ('%s') and key ('%s') for TLS context on %s: %s", file, frontend.d_tlsConfig.d_certKeyPairs.at(count).d_cert, frontend.d_tlsConfig.d_certKeyPairs.at(count).d_key.value(), frontend.d_addr.toStringWithPort(), gnutls_strerror(rc)),
+ dnsdist::logging::getTopLogger()->error(Logr::Warning, gnutls_strerror(rc), "Error loading OCSP response for TLS context", "tls.provider", Logging::Loggable("GnuTLS"), "frontend.address", Logging::Loggable(frontend.d_addr), "tls.ocsp_file", Logging::Loggable(file), "tls.certificate_file", Logging::Loggable(frontend.d_tlsConfig.d_certKeyPairs.at(count).d_cert), "tls.key_file", Logging::Loggable(frontend.d_tlsConfig.d_certKeyPairs.at(count).d_key.value())));
+#else /* DNSDIST */
warnlog("Error loading OCSP response from file '%s' for certificate ('%s') and key ('%s') for TLS context on %s: %s", file, frontend.d_tlsConfig.d_certKeyPairs.at(count).d_cert, frontend.d_tlsConfig.d_certKeyPairs.at(count).d_key.value(), frontend.d_addr.toStringWithPort(), gnutls_strerror(rc));
+#endif /* DNSDIST */
}
++count;
}