1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Added /tls trust

This commit is contained in:
James Booth 2015-11-10 23:26:19 +00:00
parent fcfdc175b6
commit 1e34b9c914
2 changed files with 21 additions and 4 deletions

View File

@ -207,6 +207,7 @@ static struct cmd_t command_defs[] =
"/tls always", "/tls always",
"/tls deny", "/tls deny",
"/tls cert", "/tls cert",
"/tls trust",
"/tls trusted", "/tls trusted",
"/tls revoke <fingerprint>", "/tls revoke <fingerprint>",
"/tls certpath", "/tls certpath",
@ -216,11 +217,12 @@ static struct cmd_t command_defs[] =
CMD_DESC( CMD_DESC(
"Handle TLS certificates. ") "Handle TLS certificates. ")
CMD_ARGS( CMD_ARGS(
{ "allow", "Allow connection to continue with an invalid TLS certificate." }, { "allow", "Allow connection to continue with TLS certificate." },
{ "always", "Always allow connections with this invalid TLS certificate." }, { "always", "Always allow connections with TLS certificate." },
{ "deny", "Terminate TLS connection." }, { "deny", "Abort connection." },
{ "cert", "Show the current TLS certificate." }, { "cert", "Show the current TLS certificate." },
{ "trusted", "List manually trusted certificates (with /tls always)." }, { "trust", "Add the current TLS certificate to manually trusted certiciates." },
{ "trusted", "List manually trusted certificates (with '/tls always' or '/tls trust')." },
{ "revoke <fingerprint>", "Remove a manually trusted certificate." }, { "revoke <fingerprint>", "Remove a manually trusted certificate." },
{ "certpath", "Show the trusted certificate path." }, { "certpath", "Show the trusted certificate path." },
{ "certpath set <path>", "Specify filesystem path containing trusted certificates." }, { "certpath set <path>", "Specify filesystem path containing trusted certificates." },
@ -2223,6 +2225,7 @@ cmd_init(void)
autocomplete_add(tls_ac, "always"); autocomplete_add(tls_ac, "always");
autocomplete_add(tls_ac, "deny"); autocomplete_add(tls_ac, "deny");
autocomplete_add(tls_ac, "cert"); autocomplete_add(tls_ac, "cert");
autocomplete_add(tls_ac, "trust");
autocomplete_add(tls_ac, "trusted"); autocomplete_add(tls_ac, "trusted");
autocomplete_add(tls_ac, "revoke"); autocomplete_add(tls_ac, "revoke");
autocomplete_add(tls_ac, "certpath"); autocomplete_add(tls_ac, "certpath");

View File

@ -193,6 +193,20 @@ cmd_tls(ProfWin *window, const char *const command, gchar **args)
#else #else
cons_show("Certificate path setting only supported when built with libmesode."); cons_show("Certificate path setting only supported when built with libmesode.");
return TRUE; return TRUE;
#endif
} else if (g_strcmp0(args[0], "trust") == 0) {
#ifdef HAVE_LIBMESODE
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 {
cons_show("Certificate %s already trusted.", cert->fingerprint);
}
return TRUE;
#else
cons_show("Manual certificate trust only supported when built with libmesode.");
return TRUE;
#endif #endif
} else if (g_strcmp0(args[0], "trusted") == 0) { } else if (g_strcmp0(args[0], "trusted") == 0) {
#ifdef HAVE_LIBMESODE #ifdef HAVE_LIBMESODE