Suggested feature: enable GnuTLS debugging output



It would be nice to be able to turn on GnuTLS's debugging features
through libsoup. Trivial patch below, probably should use libsoup's
existing logging facilities instead in some appropriate way.

--tml

Index: libsoup/soup-gnutls.c
===================================================================
--- libsoup/soup-gnutls.c	(revision 1141)
+++ libsoup/soup-gnutls.c	(working copy)
@@ -29,6 +29,8 @@
 #include "soup-ssl.h"
 #include "soup-misc.h"

+#include <stdio.h>
+
 /**
  * soup_ssl_supported:
  *
@@ -449,6 +459,12 @@
 #endif

 static void
+mylog (int level, const char *str)
+{
+  fputs (str, stdout);
+}
+
+static void
 soup_gnutls_init (void)
 {
 	static volatile gsize inited_gnutls = 0;
@@ -458,6 +474,10 @@
 		gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
 #endif
 		gnutls_global_init ();
+		if (getenv ("LIBSOUP_GNUTLS_DEBUG")) {
+			gnutls_global_set_log_level (atoi (getenv ("LIBSOUP_GNUTLS_DEBUG")));
+			gnutls_global_set_log_function (mylog);
+		}
 		g_once_init_leave (&inited_gnutls, TRUE);
 	}
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]