diff options
author | James Booth <boothj5@gmail.com> | 2015-11-11 00:57:38 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-11-11 00:57:38 +0000 |
commit | 79c2b177a2ba98ed8cbfe0c58e37ff42417e9161 (patch) | |
tree | 0db219a1ec6ed831cef81ab4415cf738e4dd80fe /src | |
parent | 1e34b9c91492e17db2983e662ec5a266c9d7bdaf (diff) | |
download | profani-tty-79c2b177a2ba98ed8cbfe0c58e37ff42417e9161.tar.gz |
Tidy /tls command
Diffstat (limited to 'src')
-rw-r--r-- | src/command/commands.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index 1a74ebc1..fe3c7045 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -196,13 +196,28 @@ cmd_tls(ProfWin *window, const char *const command, gchar **args) #endif } else if (g_strcmp0(args[0], "trust") == 0) { #ifdef HAVE_LIBMESODE + jabber_conn_status_t conn_status = jabber_get_connection_status(); + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + return TRUE; + } + if (!jabber_conn_is_secured()) { + cons_show("No TLS connection established"); + return TRUE; + } TLSCertificate *cert = jabber_get_tls_peer_cert(); - if (!tlscerts_exists(cert->fingerprint)) { - cons_show("Adding %s to trusted certificates.", cert->fingerprint); - tlscerts_add(cert); - } else { + if (!cert) { + cons_show("Error getting TLS certificate."); + return TRUE; + } + if (tlscerts_exists(cert->fingerprint)) { cons_show("Certificate %s already trusted.", cert->fingerprint); + tlscerts_free(cert); + return TRUE; } + cons_show("Adding %s to trusted certificates.", cert->fingerprint); + tlscerts_add(cert); + tlscerts_free(cert); return TRUE; #else cons_show("Manual certificate trust only supported when built with libmesode."); @@ -262,13 +277,13 @@ cmd_tls(ProfWin *window, const char *const command, gchar **args) return TRUE; } TLSCertificate *cert = jabber_get_tls_peer_cert(); - if (cert) { - cons_show_tlscert(cert); - cons_show(""); - tlscerts_free(cert); - } else { - cons_show("Error getting TLS fingerprint."); + if (!cert) { + cons_show("Error getting TLS certificate."); + return TRUE; } + cons_show_tlscert(cert); + cons_show(""); + tlscerts_free(cert); return TRUE; #else cons_show("Certificate fetching not supported."); |