mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-22 17:36:22 +00:00
Store current TLS certificate fingerpint in memory for reconnect
This commit is contained in:
@@ -51,6 +51,8 @@ static void _save_tlscerts(void);
|
||||
|
||||
static Autocomplete certs_ac;
|
||||
|
||||
static char *current_fp;
|
||||
|
||||
void
|
||||
tlscerts_init(void)
|
||||
{
|
||||
@@ -73,6 +75,32 @@ tlscerts_init(void)
|
||||
autocomplete_add(certs_ac, groups[i]);
|
||||
}
|
||||
g_strfreev(groups);
|
||||
|
||||
current_fp = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
tlscerts_set_current(const char *const fp)
|
||||
{
|
||||
if (current_fp) {
|
||||
free(current_fp);
|
||||
}
|
||||
current_fp = strdup(fp);
|
||||
}
|
||||
|
||||
char*
|
||||
tlscerts_get_current(void)
|
||||
{
|
||||
return current_fp;
|
||||
}
|
||||
|
||||
void
|
||||
tlscerts_clear_current(void)
|
||||
{
|
||||
if (current_fp) {
|
||||
free(current_fp);
|
||||
current_fp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -223,6 +251,10 @@ tlscerts_close(void)
|
||||
{
|
||||
g_key_file_free(tlscerts);
|
||||
tlscerts = NULL;
|
||||
|
||||
free(current_fp);
|
||||
current_fp = NULL;
|
||||
|
||||
autocomplete_free(certs_ac);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,12 @@ TLSCertificate* tlscerts_new(const char *const fingerprint, const char *const do
|
||||
const char *const organisation, const char *const email,
|
||||
const char *const notbefore, const char *const notafter);
|
||||
|
||||
void tlscerts_set_current(const char *const fp);
|
||||
|
||||
char* tlscerts_get_current(void);
|
||||
|
||||
void tlscerts_clear_current(void);
|
||||
|
||||
gboolean tlscerts_exists(const char *const fingerprint);
|
||||
|
||||
void tlscerts_add(TLSCertificate *cert);
|
||||
|
||||
Reference in New Issue
Block a user