]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Tweaks and man page updates
authorOtto <otto.moerbeek@open-xchange.com>
Fri, 5 Feb 2021 10:01:37 +0000 (11:01 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Fri, 5 Feb 2021 10:25:36 +0000 (11:25 +0100)
docs/manpages/sdig.1.rst
pdns/libssl.cc
pdns/libssl.hh
pdns/sdig.cc
pdns/tcpiohandler.cc

index 3fc868b96c88b987d6d01dd6075f398a1b3fa353..eeda8dc29e452647936d57ae8328bc8acdb0e736 100644 (file)
@@ -39,6 +39,16 @@ showflags
     Show the NSEC3 flags in the response (they are hidden by default).
 tcp
     Use TCP instead of UDP to send the query.
+dot
+    use DoT instead of UDP to send a query. Implies tcp.
+insecure
+    when using DoT, do not validate the server certificate.
+subjectName *name*
+    when using DoT, verify the server certificate is issued for *name*.
+caStore *file*
+    when using Dot, read the trusted CA certificates from *file*. Default is to use the system provided CA store.
+tlsProvider *name*
+    when using DoT, use TLS provider *name*. Currently supported (if compiled in): `openssl` and `gnutls`. Default is `openssl` if available.
 xpf *XPFCODE* *XPFVERSION* *XPFPROTO* *XPFSRC* *XPFDST*
        Send an *XPF* additional with these parameters.
 
index deffcdbf49e5af3bf0b0673cf9c6cc929bd5a937..af08817c1f19aac33462906f407684fc8e38e988 100644 (file)
@@ -782,4 +782,19 @@ std::unique_ptr<FILE, int(*)(FILE*)> libssl_set_key_log_file(std::unique_ptr<SSL
 #endif /* HAVE_SSL_CTX_SET_KEYLOG_CALLBACK */
 }
 
+std::string libssl_get_error_string()
+{
+  BIO *mem = BIO_new(BIO_s_mem());
+  ERR_print_errors(mem);
+  char *p;
+  size_t len = BIO_get_mem_data(mem, &p);
+  std::string msg(p, len);
+  // replace newlines by /
+  if (msg.back() == '\n') {
+    msg.pop_back();
+  }
+  std::replace(msg.begin(), msg.end(), '\n', '/');
+  BIO_free(mem);
+  return msg;
+}
 #endif /* HAVE_LIBSSL */
index bdca6eaa140b82d40a4969a6f3a05b84aae0fedf..849b73c862fc03b4b238cb37d2cf36be755dff46 100644 (file)
@@ -120,4 +120,7 @@ std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)> libssl_init_server_context(const TLS
                                                                        std::map<int, std::string>& ocspResponses);
 
 std::unique_ptr<FILE, int(*)(FILE*)> libssl_set_key_log_file(std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)>& ctx, const std::string& logFile);
+
+std::string libssl_get_error_string();
+
 #endif /* HAVE_LIBSSL */
index afaef8ee807578ac511b32c632ccfc18c20471ac..85f05e194302c341f656820d0e74b9129c5c12a9 100644 (file)
@@ -39,7 +39,7 @@ static void usage()
   cerr << "sdig" << endl;
   cerr << "Syntax: sdig IP-ADDRESS-OR-DOH-URL PORT QNAME QTYPE "
           "[dnssec] [ednssubnet SUBNET/MASK] [hidesoadetails] [hidettl] [recurse] [showflags] "
-          "[tcp] [dot] [insecure] [subjectName name] [caStore file] [tlsProvider provider] "
+          "[tcp] [dot] [insecure] [subjectName name] [caStore file] [tlsProvider openssl|gnutls] "
           "[xpf XPFDATA] [class CLASSNUM] "
           "[proxy UDP(0)/TCP(1) SOURCE-IP-ADDRESS-AND-PORT DESTINATION-IP-ADDRESS-AND-PORT]"
        << endl;
index dd6429b77bd8461c7f24af01486c2518aa8d936a..13aefa77c62e21bf7ad8291ad0796d16a1d7ea05 100644 (file)
@@ -125,8 +125,11 @@ public:
       throw std::runtime_error("Syscall error while processing TLS connection: " + std::string(strerror(errno)));
     }
     else {
-      ERR_print_errors_fp(stderr);
-      throw std::runtime_error("Error while processing TLS connection: " + std::to_string(error));
+      if (g_verbose) {
+        throw std::runtime_error("Error while processing TLS connection: " + libssl_get_error_string());
+      } else {
+        throw std::runtime_error("Error while processing TLS connection: " + std::to_string(error));
+      }
     }
   }
 
@@ -383,7 +386,7 @@ class OpenSSLTLSIOCtx: public TLSCtx
 {
 public:
   /* server side context */
-  OpenSSLTLSIOCtx(TLSFrontend& fe): d_feContext(std::make_shared<OpenSSLFrontendContext>(fe.d_addr, fe.d_tlsConfig)), d_ticketKeys{0}, d_tlsCtx(std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)>(nullptr, SSL_CTX_free))
+  OpenSSLTLSIOCtx(TLSFrontend& fe): d_feContext(std::make_shared<OpenSSLFrontendContext>(fe.d_addr, fe.d_tlsConfig)), d_tlsCtx(std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)>(nullptr, SSL_CTX_free))
   {
     d_ticketsKeyRotationDelay = fe.d_tlsConfig.d_ticketsKeyRotationDelay;
 
@@ -418,7 +421,7 @@ public:
   }
 
   /* client side context */
-  OpenSSLTLSIOCtx(const TLSContextParameters& params): d_ticketKeys(0), d_tlsCtx(std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)>(nullptr, SSL_CTX_free))
+  OpenSSLTLSIOCtx(const TLSContextParameters& params): d_tlsCtx(std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)>(nullptr, SSL_CTX_free))
   {
     int sslOptions =
       SSL_OP_NO_SSLv2 |
@@ -430,13 +433,6 @@ public:
       SSL_OP_CIPHER_SERVER_PREFERENCE;
 
     registerOpenSSLUser();
-#if 0 // XXX
-    s_ticketsKeyIndex = SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr);
-    
-    if (s_ticketsKeyIndex == -1) {
-      throw std::runtime_error("Error getting an index for tickets key");
-    }
-#endif
 
 #ifdef HAVE_TLS_CLIENT_METHOD
     d_tlsCtx = std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)>(SSL_CTX_new(TLS_client_method()), SSL_CTX_free);
@@ -563,9 +559,7 @@ public:
 
 private:
   std::shared_ptr<OpenSSLFrontendContext> d_feContext;
-  OpenSSLTLSTicketKeysRing d_ticketKeys;
-  std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)> d_tlsCtx;
-  static std::atomic<uint64_t> s_users;
+  std::unique_ptr<SSL_CTX, void(*)(SSL_CTX*)> d_tlsCtx; // client context
 };
 
 #endif /* HAVE_LIBSSL */