Add /tls certpath default

issue #871
This commit is contained in:
James Booth
2016-10-17 23:48:03 +01:00
parent 0e1df8c542
commit 5b464f4cb0
6 changed files with 53 additions and 5 deletions

View File

@@ -683,6 +683,7 @@ cmd_ac_init(void)
tls_certpath_ac = autocomplete_new();
autocomplete_add(tls_certpath_ac, "set");
autocomplete_add(tls_certpath_ac, "clear");
autocomplete_add(tls_certpath_ac, "default");
script_ac = autocomplete_new();
autocomplete_add(script_ac, "run");

View File

@@ -200,6 +200,7 @@ static struct cmd_t command_defs[] =
"/tls certpath",
"/tls certpath set <path>",
"/tls certpath clear",
"/tls certpath default",
"/tls show on|off")
CMD_DESC(
"Handle TLS certificates. ")
@@ -215,6 +216,7 @@ static struct cmd_t command_defs[] =
{ "certpath", "Show the trusted certificate path." },
{ "certpath set <path>", "Specify filesystem path containing trusted certificates." },
{ "certpath clear", "Clear the trusted certificate path." },
{ "certpath default", "Use default system certificate path, if it can be found." },
{ "show on|off", "Show or hide the TLS indicator in the titlebar." })
CMD_NOEXAMPLES
},

View File

@@ -171,14 +171,18 @@ cmd_tls_certpath(ProfWin *window, const char *const command, gchar **args)
}
return TRUE;
} else if (g_strcmp0(args[1], "clear") == 0) {
prefs_set_string(PREF_TLS_CERTPATH, NULL);
prefs_set_string(PREF_TLS_CERTPATH, "none");
cons_show("Certificate path cleared");
return TRUE;
} else if (g_strcmp0(args[1], "default") == 0) {
prefs_set_string(PREF_TLS_CERTPATH, NULL);
cons_show("Certificate path defaulted to finding system certpath.");
return TRUE;
} else if (args[1] == NULL) {
char *path = prefs_get_string(PREF_TLS_CERTPATH);
char *path = prefs_get_tls_certpath();
if (path) {
cons_show("Trusted certificate path: %s", path);
prefs_free_string(path);
free(path);
} else {
cons_show("No trusted certificate path set.");
}