]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: add a global loadTicketsKey function
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Wed, 9 Oct 2024 14:21:27 +0000 (16:21 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 25 Nov 2024 16:03:22 +0000 (17:03 +0100)
(cherry picked from commit eb8748356f51bec98dd0626e18627d2552858d07)

pdns/dnsdist-lua.cc
pdns/dnsdistdist/docs/reference/config.rst

index 2f57d547fe5f2d2fe244ca9ad549f25f1cbf5b62..49c353c9477fbdfb105aff8d3858d3781c2e86dc 100644 (file)
@@ -3064,6 +3064,29 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
     }
   });
 
+  luaCtx.writeFunction("loadTicketsKey", [](const std::string& key) {
+    for (auto& frontend : g_frontends) {
+      if (!frontend) {
+        continue;
+      }
+      try {
+#ifdef HAVE_DNS_OVER_TLS
+       if (frontend->tlsFrontend) {
+         frontend->tlsFrontend->loadTicketsKey(key);
+       }
+#endif /* HAVE_DNS_OVER_TLS */
+#ifdef HAVE_DNS_OVER_HTTPS
+       if (frontend->dohFrontend) {
+         frontend->dohFrontend->loadTicketsKey(key);
+       }
+#endif /* HAVE_DNS_OVER_HTTPS */
+      }
+      catch (const std::exception& e) {
+        errlog("Error loading given tickets key for local %s", frontend->local.toStringWithPort());
+      }
+    }
+  });
+
   luaCtx.registerFunction<void (std::shared_ptr<DOHFrontend>::*)(const LuaArray<std::shared_ptr<DOHResponseMapEntry>>&)>("setResponsesMap", [](std::shared_ptr<DOHFrontend> frontend, const LuaArray<std::shared_ptr<DOHResponseMapEntry>>& map) {
     if (frontend != nullptr) {
       auto newMap = std::make_shared<std::vector<std::shared_ptr<DOHResponseMapEntry>>>();
index b6d9bcf86e7b1cd4987d16711397156eded0d8f7..5f283e03487fd1da298d9783e7974c478e6d6fb3 100644 (file)
@@ -52,6 +52,12 @@ Global configuration
 
   :param str path: The directory to load configuration files from. Each file must end in ``.conf``.
 
+.. function:: loadTicketsKey(key)
+
+  Load the given TLS tickets key on all compatible frontends (DOH and TLS).
+
+  :param str key: The new raw TLS tickets key to use.
+
 .. function:: reloadAllCertificates()
 
   .. versionadded:: 1.4.0
@@ -2251,6 +2257,12 @@ DOHFrontend
 
     :param str ticketsKeysFile: The path to a file from where TLS tickets keys should be loaded.
 
+  .. method:: DOHFrontend:loadTicketsKey(key)
+
+     Replace the current TLS tickets key with a given one.
+
+     :param str key: the new raw TLS tickets key to load.
+
   .. method:: DOHFrontend:reloadCertificates()
 
      Reload the current TLS certificate and key pairs.
@@ -2430,6 +2442,12 @@ TLSFrontend
 
     :param str ticketsKeysFile: The path to a file from where TLS tickets keys should be loaded.
 
+  .. method:: TLSFrontend:loadTicketsKey(key)
+
+     Replace the current TLS tickets key with a given one.
+
+    :param str key: the new raw TLS tickets key to load.
+
   .. method:: TLSFrontend:reloadCertificates()
 
   .. versionadded:: 1.6.0