about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-09-24 00:43:41 +0100
committerJames Booth <boothj5@gmail.com>2015-09-24 00:43:41 +0100
commit6f8ad6b8e80da98273870ea1b241065418a26367 (patch)
tree2bde89e3382ae38d1133bb87f9603a12434c1ce0 /src/command
parentd96e68ea53c6457dbbd441d6dbe13c5c994d7a22 (diff)
downloadprofani-tty-6f8ad6b8e80da98273870ea1b241065418a26367.tar.gz
Added /tls trusted command
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c3
-rw-r--r--src/command/commands.c34
2 files changed, 37 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 669fb066..bb440bbf 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -195,6 +195,7 @@ static struct cmd_t command_defs[] =
             "/tls allow",
             "/tls always",
             "/tls deny",
+            "/tls trusted",
             "/tls certpath",
             "/tls certpath set <path>",
             "/tls certpath clear")
@@ -204,6 +205,7 @@ static struct cmd_t command_defs[] =
             { "allow",               "Allow connection to continue with an invalid TLS certificate." },
             { "always",              "Always allow connections with this invalid TLS certificate." },
             { "deny",                "Terminate TLS connection." },
+            { "trusted",             "List manually trusted certificates." },
             { "certpath",            "Show the trusted certificate path." },
             { "certpath set <path>", "Specify filesystem path containing trusted certificates." },
             { "certpath clear",      "Clear the trusted certificate path." })
@@ -2100,6 +2102,7 @@ cmd_init(void)
     autocomplete_add(tls_ac, "allow");
     autocomplete_add(tls_ac, "always");
     autocomplete_add(tls_ac, "deny");
+    autocomplete_add(tls_ac, "trusted");
     autocomplete_add(tls_ac, "certpath");
 
     tls_certpath_ac = autocomplete_new();
diff --git a/src/command/commands.c b/src/command/commands.c
index 8c2b70ec..70f41a6d 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -49,6 +49,7 @@
 #include "config/account.h"
 #include "config/preferences.h"
 #include "config/theme.h"
+#include "config/tlscerts.h"
 #include "contact.h"
 #include "roster_list.h"
 #include "jid.h"
@@ -190,6 +191,39 @@ cmd_tls(ProfWin *window, const char * const command, gchar **args)
             cons_bad_cmd_usage(command);
             return TRUE;
         }
+    } else if (g_strcmp0(args[0], "trusted") == 0) {
+        GList *certs = tlscerts_list();
+        GList *curr = certs;
+
+        if (curr) {
+            cons_show("Trusted certificates:");
+            cons_show("");
+        }
+        while (curr) {
+            TLSCertificate *cert = curr->data;
+            if (cert->domain) {
+                cons_show("Domain       : %s", cert->domain);
+            }
+            if (cert->organisation) {
+                cons_show("Organisation : %s", cert->organisation);
+            }
+            if (cert->email) {
+                cons_show("Email        : %s", cert->email);
+            }
+            if (cert->notbefore) {
+                cons_show("Start        : %s", cert->notbefore);
+            }
+            if (cert->notafter) {
+                cons_show("End          : %s", cert->notafter);
+            }
+            if (cert->fingerprint) {
+                cons_show("Fingerprint  : %s", cert->fingerprint);
+            }
+            cons_show("");
+            curr = g_list_next(curr);
+        }
+        g_list_free_full(certs, (GDestroyNotify)tlscerts_free);
+        return TRUE;
     } else {
         cons_bad_cmd_usage(command);
         return TRUE;