2015-09-23 19:18:18 -04:00
|
|
|
/*
|
|
|
|
* tlscerts.c
|
2019-11-13 06:11:05 -05:00
|
|
|
* vim: expandtab:ts=4:sts=4:sw=4
|
2015-09-23 19:18:18 -04:00
|
|
|
*
|
2019-01-22 05:31:45 -05:00
|
|
|
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
2015-09-23 19:18:18 -04:00
|
|
|
*
|
|
|
|
* This file is part of Profanity.
|
|
|
|
*
|
|
|
|
* Profanity is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Profanity is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-07-23 20:14:49 -04:00
|
|
|
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
2015-09-23 19:18:18 -04:00
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link the code of portions of this program with the OpenSSL library under
|
|
|
|
* certain conditions as described in each individual source file, and
|
|
|
|
* distribute linked combinations including the two.
|
|
|
|
*
|
|
|
|
* You must obey the GNU General Public License in all respects for all of the
|
|
|
|
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
|
|
|
* may extend this exception to your version of the file(s), but you are not
|
|
|
|
* obligated to do so. If you do not wish to do so, delete this exception
|
|
|
|
* statement from your version. If you delete this exception statement from all
|
|
|
|
* source files in the program, then also delete it here.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "common.h"
|
2016-07-24 11:22:15 -04:00
|
|
|
#include "config/files.h"
|
2016-07-24 10:43:51 -04:00
|
|
|
#include "config/tlscerts.h"
|
2015-09-23 20:06:53 -04:00
|
|
|
#include "tools/autocomplete.h"
|
2015-09-23 19:18:18 -04:00
|
|
|
|
2016-07-24 16:35:12 -04:00
|
|
|
static char *tlscerts_loc;
|
2015-09-23 19:18:18 -04:00
|
|
|
static GKeyFile *tlscerts;
|
|
|
|
|
|
|
|
static void _save_tlscerts(void);
|
|
|
|
|
2015-09-23 20:06:53 -04:00
|
|
|
static Autocomplete certs_ac;
|
|
|
|
|
2015-11-09 15:57:26 -05:00
|
|
|
static char *current_fp;
|
|
|
|
|
2015-09-23 19:18:18 -04:00
|
|
|
void
|
|
|
|
tlscerts_init(void)
|
|
|
|
{
|
|
|
|
log_info("Loading TLS certificates");
|
2016-07-24 16:35:12 -04:00
|
|
|
tlscerts_loc = files_get_data_path(FILE_TLSCERTS);
|
2015-09-23 19:18:18 -04:00
|
|
|
|
|
|
|
if (g_file_test(tlscerts_loc, G_FILE_TEST_EXISTS)) {
|
|
|
|
g_chmod(tlscerts_loc, S_IRUSR | S_IWUSR);
|
|
|
|
}
|
|
|
|
|
|
|
|
tlscerts = g_key_file_new();
|
|
|
|
g_key_file_load_from_file(tlscerts, tlscerts_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
2015-09-23 20:06:53 -04:00
|
|
|
|
|
|
|
certs_ac = autocomplete_new();
|
|
|
|
gsize len = 0;
|
|
|
|
gchar **groups = g_key_file_get_groups(tlscerts, &len);
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for (i = 0; i < g_strv_length(groups); i++) {
|
|
|
|
autocomplete_add(certs_ac, groups[i]);
|
|
|
|
}
|
|
|
|
g_strfreev(groups);
|
2015-11-09 15:57:26 -05:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2015-09-23 19:18:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2015-10-25 18:23:38 -04:00
|
|
|
tlscerts_exists(const char *const fingerprint)
|
2015-09-23 19:18:18 -04:00
|
|
|
{
|
|
|
|
return g_key_file_has_group(tlscerts, fingerprint);
|
|
|
|
}
|
|
|
|
|
2015-09-23 19:43:41 -04:00
|
|
|
GList*
|
|
|
|
tlscerts_list(void)
|
|
|
|
{
|
|
|
|
GList *res = NULL;
|
|
|
|
gsize len = 0;
|
|
|
|
gchar **groups = g_key_file_get_groups(tlscerts, &len);
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for (i = 0; i < g_strv_length(groups); i++) {
|
|
|
|
char *fingerprint = strdup(groups[i]);
|
2015-11-10 17:46:48 -05:00
|
|
|
int version = g_key_file_get_integer(tlscerts, fingerprint, "version", NULL);
|
|
|
|
char *serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
|
2015-11-09 20:20:40 -05:00
|
|
|
char *subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
|
2015-11-10 17:46:48 -05:00
|
|
|
char *issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
|
2015-09-23 19:43:41 -04:00
|
|
|
char *notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
|
|
|
|
char *notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
|
2015-11-10 17:46:48 -05:00
|
|
|
char *keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
|
|
|
|
char *signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
|
2015-09-23 19:43:41 -04:00
|
|
|
|
2015-11-10 17:46:48 -05:00
|
|
|
TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
|
|
|
notafter, keyalg, signaturealg);
|
2015-09-23 19:43:41 -04:00
|
|
|
|
2015-11-22 14:53:41 -05:00
|
|
|
free(fingerprint);
|
|
|
|
free(serialnumber);
|
|
|
|
free(subjectname);
|
|
|
|
free(issuername);
|
|
|
|
free(notbefore);
|
|
|
|
free(notafter);
|
|
|
|
free(keyalg);
|
|
|
|
free(signaturealg);
|
|
|
|
|
2015-09-23 19:43:41 -04:00
|
|
|
res = g_list_append(res, cert);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groups) {
|
|
|
|
g_strfreev(groups);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-09-23 19:18:18 -04:00
|
|
|
TLSCertificate*
|
2015-11-10 17:46:48 -05:00
|
|
|
tlscerts_new(const char *const fingerprint, int version, const char *const serialnumber, const char *const subjectname,
|
|
|
|
const char *const issuername, const char *const notbefore, const char *const notafter,
|
|
|
|
const char *const key_alg, const char *const signature_alg)
|
2015-09-23 19:18:18 -04:00
|
|
|
{
|
|
|
|
TLSCertificate *cert = malloc(sizeof(TLSCertificate));
|
2015-11-09 20:20:40 -05:00
|
|
|
|
2015-11-10 17:46:48 -05:00
|
|
|
if (fingerprint) {
|
|
|
|
cert->fingerprint = strdup(fingerprint);
|
|
|
|
} else {
|
|
|
|
cert->fingerprint = NULL;
|
|
|
|
}
|
|
|
|
cert->version = version;
|
|
|
|
if (serialnumber) {
|
|
|
|
cert->serialnumber = strdup(serialnumber);
|
|
|
|
} else {
|
|
|
|
cert->serialnumber = NULL;
|
|
|
|
}
|
2015-11-09 20:20:40 -05:00
|
|
|
if (subjectname) {
|
|
|
|
cert->subjectname = strdup(subjectname);
|
|
|
|
} else {
|
|
|
|
cert->subjectname = NULL;
|
|
|
|
}
|
2015-11-10 17:46:48 -05:00
|
|
|
if (issuername) {
|
|
|
|
cert->issuername = strdup(issuername);
|
2015-09-23 19:18:18 -04:00
|
|
|
} else {
|
2015-11-10 17:46:48 -05:00
|
|
|
cert->issuername = NULL;
|
2015-09-23 19:18:18 -04:00
|
|
|
}
|
|
|
|
if (notbefore) {
|
|
|
|
cert->notbefore = strdup(notbefore);
|
|
|
|
} else {
|
|
|
|
cert->notbefore = NULL;
|
|
|
|
}
|
|
|
|
if (notafter) {
|
|
|
|
cert->notafter = strdup(notafter);
|
|
|
|
} else {
|
|
|
|
cert->notafter = NULL;
|
|
|
|
}
|
2015-11-10 17:46:48 -05:00
|
|
|
if (key_alg) {
|
|
|
|
cert->key_alg = strdup(key_alg);
|
|
|
|
} else {
|
|
|
|
cert->key_alg = NULL;
|
|
|
|
}
|
|
|
|
if (signature_alg) {
|
|
|
|
cert->signature_alg = strdup(signature_alg);
|
|
|
|
} else {
|
|
|
|
cert->signature_alg = NULL;
|
|
|
|
}
|
2015-09-23 19:18:18 -04:00
|
|
|
|
2015-11-10 17:46:48 -05:00
|
|
|
cert->subject_country = NULL;
|
|
|
|
cert->subject_state = NULL;
|
|
|
|
cert->subject_distinguishedname = NULL;
|
|
|
|
cert->subject_serialnumber = NULL;
|
|
|
|
cert->subject_commonname = NULL;
|
|
|
|
cert->subject_organisation = NULL;
|
|
|
|
cert->subject_organisation_unit = NULL;
|
|
|
|
cert->subject_email = NULL;
|
2015-11-09 20:20:40 -05:00
|
|
|
gchar** fields = g_strsplit(subjectname, "/", 0);
|
|
|
|
int i = 0;
|
|
|
|
for (i = 0; i < g_strv_length(fields); i++) {
|
|
|
|
gchar** keyval = g_strsplit(fields[i], "=", 2);
|
|
|
|
if (g_strv_length(keyval) == 2) {
|
2015-11-10 17:46:48 -05:00
|
|
|
if ((g_strcmp0(keyval[0], "C") == 0) || (g_strcmp0(keyval[0], "countryName") == 0)) {
|
|
|
|
cert->subject_country = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if ((g_strcmp0(keyval[0], "ST") == 0) || (g_strcmp0(keyval[0], "stateOrProvinceName") == 0)) {
|
|
|
|
cert->subject_state = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if (g_strcmp0(keyval[0], "dnQualifier") == 0) {
|
|
|
|
cert->subject_distinguishedname = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if (g_strcmp0(keyval[0], "serialnumber") == 0) {
|
|
|
|
cert->subject_serialnumber = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if ((g_strcmp0(keyval[0], "CN") == 0) || (g_strcmp0(keyval[0], "commonName") == 0)) {
|
|
|
|
cert->subject_commonname = strdup(keyval[1]);
|
2015-11-09 20:20:40 -05:00
|
|
|
}
|
2015-11-10 17:46:48 -05:00
|
|
|
if ((g_strcmp0(keyval[0], "O") == 0) || (g_strcmp0(keyval[0], "organizationName") == 0)) {
|
|
|
|
cert->subject_organisation = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if ((g_strcmp0(keyval[0], "OU") == 0) || (g_strcmp0(keyval[0], "organizationalUnitName") == 0)) {
|
|
|
|
cert->subject_organisation_unit = strdup(keyval[1]);
|
2015-11-09 20:20:40 -05:00
|
|
|
}
|
|
|
|
if (g_strcmp0(keyval[0], "emailAddress") == 0) {
|
2015-11-10 17:46:48 -05:00
|
|
|
cert->subject_email = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_strfreev(keyval);
|
|
|
|
}
|
|
|
|
g_strfreev(fields);
|
|
|
|
|
|
|
|
cert->issuer_country = NULL;
|
|
|
|
cert->issuer_state = NULL;
|
|
|
|
cert->issuer_distinguishedname = NULL;
|
|
|
|
cert->issuer_serialnumber = NULL;
|
|
|
|
cert->issuer_commonname = NULL;
|
|
|
|
cert->issuer_organisation = NULL;
|
|
|
|
cert->issuer_organisation_unit = NULL;
|
|
|
|
cert->issuer_email = NULL;
|
|
|
|
fields = g_strsplit(issuername, "/", 0);
|
|
|
|
for (i = 0; i < g_strv_length(fields); i++) {
|
|
|
|
gchar** keyval = g_strsplit(fields[i], "=", 2);
|
|
|
|
if (g_strv_length(keyval) == 2) {
|
|
|
|
if ((g_strcmp0(keyval[0], "C") == 0) || (g_strcmp0(keyval[0], "countryName") == 0)) {
|
|
|
|
cert->issuer_country = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if ((g_strcmp0(keyval[0], "ST") == 0) || (g_strcmp0(keyval[0], "stateOrProvinceName") == 0)) {
|
|
|
|
cert->issuer_state = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if (g_strcmp0(keyval[0], "dnQualifier") == 0) {
|
|
|
|
cert->issuer_distinguishedname = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if (g_strcmp0(keyval[0], "serialnumber") == 0) {
|
|
|
|
cert->issuer_serialnumber = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if ((g_strcmp0(keyval[0], "CN") == 0) || (g_strcmp0(keyval[0], "commonName") == 0)) {
|
|
|
|
cert->issuer_commonname = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if ((g_strcmp0(keyval[0], "O") == 0) || (g_strcmp0(keyval[0], "organizationName") == 0)) {
|
|
|
|
cert->issuer_organisation = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if ((g_strcmp0(keyval[0], "OU") == 0) || (g_strcmp0(keyval[0], "organizationalUnitName") == 0)) {
|
|
|
|
cert->issuer_organisation_unit = strdup(keyval[1]);
|
|
|
|
}
|
|
|
|
if (g_strcmp0(keyval[0], "emailAddress") == 0) {
|
|
|
|
cert->issuer_email = strdup(keyval[1]);
|
2015-11-09 20:20:40 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
g_strfreev(keyval);
|
|
|
|
}
|
|
|
|
g_strfreev(fields);
|
|
|
|
|
2015-09-23 19:18:18 -04:00
|
|
|
return cert;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tlscerts_add(TLSCertificate *cert)
|
|
|
|
{
|
|
|
|
if (!cert) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cert->fingerprint) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-23 20:06:53 -04:00
|
|
|
autocomplete_add(certs_ac, cert->fingerprint);
|
|
|
|
|
2015-11-10 17:46:48 -05:00
|
|
|
g_key_file_set_integer(tlscerts, cert->fingerprint, "version", cert->version);
|
|
|
|
if (cert->serialnumber) {
|
|
|
|
g_key_file_set_string(tlscerts, cert->fingerprint, "serialnumber", cert->serialnumber);
|
|
|
|
}
|
2015-11-09 20:20:40 -05:00
|
|
|
if (cert->subjectname) {
|
|
|
|
g_key_file_set_string(tlscerts, cert->fingerprint, "subjectname", cert->subjectname);
|
2015-09-23 19:18:18 -04:00
|
|
|
}
|
2015-11-10 17:46:48 -05:00
|
|
|
if (cert->issuername) {
|
|
|
|
g_key_file_set_string(tlscerts, cert->fingerprint, "issuername", cert->issuername);
|
|
|
|
}
|
2015-09-23 19:18:18 -04:00
|
|
|
if (cert->notbefore) {
|
|
|
|
g_key_file_set_string(tlscerts, cert->fingerprint, "start", cert->notbefore);
|
|
|
|
}
|
|
|
|
if (cert->notafter) {
|
|
|
|
g_key_file_set_string(tlscerts, cert->fingerprint, "end", cert->notafter);
|
|
|
|
}
|
2015-11-10 17:46:48 -05:00
|
|
|
if (cert->key_alg) {
|
|
|
|
g_key_file_set_string(tlscerts, cert->fingerprint, "keyalg", cert->key_alg);
|
|
|
|
}
|
|
|
|
if (cert->signature_alg) {
|
|
|
|
g_key_file_set_string(tlscerts, cert->fingerprint, "signaturealg", cert->signature_alg);
|
|
|
|
}
|
2015-09-23 19:18:18 -04:00
|
|
|
|
|
|
|
_save_tlscerts();
|
|
|
|
}
|
|
|
|
|
2015-09-23 20:06:53 -04:00
|
|
|
gboolean
|
2015-10-25 18:23:38 -04:00
|
|
|
tlscerts_revoke(const char *const fingerprint)
|
2015-09-23 20:06:53 -04:00
|
|
|
{
|
|
|
|
gboolean result = g_key_file_remove_group(tlscerts, fingerprint, NULL);
|
|
|
|
if (result) {
|
|
|
|
autocomplete_remove(certs_ac, fingerprint);
|
|
|
|
}
|
|
|
|
|
|
|
|
_save_tlscerts();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-11-22 14:53:41 -05:00
|
|
|
TLSCertificate*
|
|
|
|
tlscerts_get_trusted(const char * const fingerprint)
|
|
|
|
{
|
|
|
|
if (!g_key_file_has_group(tlscerts, fingerprint)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int version = g_key_file_get_integer(tlscerts, fingerprint, "version", NULL);
|
|
|
|
char *serialnumber = g_key_file_get_string(tlscerts, fingerprint, "serialnumber", NULL);
|
|
|
|
char *subjectname = g_key_file_get_string(tlscerts, fingerprint, "subjectname", NULL);
|
|
|
|
char *issuername = g_key_file_get_string(tlscerts, fingerprint, "issuername", NULL);
|
|
|
|
char *notbefore = g_key_file_get_string(tlscerts, fingerprint, "start", NULL);
|
|
|
|
char *notafter = g_key_file_get_string(tlscerts, fingerprint, "end", NULL);
|
|
|
|
char *keyalg = g_key_file_get_string(tlscerts, fingerprint, "keyalg", NULL);
|
|
|
|
char *signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL);
|
|
|
|
|
|
|
|
TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
|
|
|
|
notafter, keyalg, signaturealg);
|
|
|
|
|
|
|
|
free(serialnumber);
|
|
|
|
free(subjectname);
|
|
|
|
free(issuername);
|
|
|
|
free(notbefore);
|
|
|
|
free(notafter);
|
|
|
|
free(keyalg);
|
|
|
|
free(signaturealg);
|
|
|
|
|
|
|
|
return cert;
|
|
|
|
}
|
|
|
|
|
2015-10-25 18:23:38 -04:00
|
|
|
char*
|
2020-01-30 17:44:43 -05:00
|
|
|
tlscerts_complete(const char *const prefix, gboolean previous, void *context)
|
2015-09-23 20:06:53 -04:00
|
|
|
{
|
2017-03-31 19:27:11 -04:00
|
|
|
return autocomplete_complete(certs_ac, prefix, TRUE, previous);
|
2015-09-23 20:06:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tlscerts_reset_ac(void)
|
|
|
|
{
|
|
|
|
autocomplete_reset(certs_ac);
|
|
|
|
}
|
|
|
|
|
2015-09-23 19:18:18 -04:00
|
|
|
void
|
|
|
|
tlscerts_free(TLSCertificate *cert)
|
|
|
|
{
|
|
|
|
if (cert) {
|
2015-11-10 17:46:48 -05:00
|
|
|
free(cert->serialnumber);
|
|
|
|
|
2015-11-09 20:20:40 -05:00
|
|
|
free(cert->subjectname);
|
2015-11-10 17:46:48 -05:00
|
|
|
free(cert->subject_country);
|
|
|
|
free(cert->subject_state);
|
|
|
|
free(cert->subject_distinguishedname);
|
|
|
|
free(cert->subject_serialnumber);
|
|
|
|
free(cert->subject_commonname);
|
|
|
|
free(cert->subject_organisation);
|
|
|
|
free(cert->subject_organisation_unit);
|
|
|
|
free(cert->subject_email);
|
|
|
|
|
|
|
|
free(cert->issuername);
|
|
|
|
free(cert->issuer_country);
|
|
|
|
free(cert->issuer_state);
|
|
|
|
free(cert->issuer_distinguishedname);
|
|
|
|
free(cert->issuer_serialnumber);
|
|
|
|
free(cert->issuer_commonname);
|
|
|
|
free(cert->issuer_organisation);
|
|
|
|
free(cert->issuer_organisation_unit);
|
|
|
|
free(cert->issuer_email);
|
|
|
|
|
2015-09-23 19:18:18 -04:00
|
|
|
free(cert->notbefore);
|
|
|
|
free(cert->notafter);
|
2015-11-10 17:46:48 -05:00
|
|
|
free(cert->fingerprint);
|
|
|
|
|
|
|
|
free(cert->key_alg);
|
|
|
|
free(cert->signature_alg);
|
2016-03-08 15:25:36 -05:00
|
|
|
|
|
|
|
free(cert);
|
2015-09-23 19:18:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tlscerts_close(void)
|
|
|
|
{
|
|
|
|
g_key_file_free(tlscerts);
|
|
|
|
tlscerts = NULL;
|
2015-11-09 15:57:26 -05:00
|
|
|
|
|
|
|
free(current_fp);
|
|
|
|
current_fp = NULL;
|
|
|
|
|
2015-09-23 20:06:53 -04:00
|
|
|
autocomplete_free(certs_ac);
|
2015-09-23 19:18:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_save_tlscerts(void)
|
|
|
|
{
|
|
|
|
gsize g_data_size;
|
|
|
|
gchar *g_tlscerts_data = g_key_file_to_data(tlscerts, &g_data_size, NULL);
|
|
|
|
g_file_set_contents(tlscerts_loc, g_tlscerts_data, g_data_size, NULL);
|
|
|
|
g_chmod(tlscerts_loc, S_IRUSR | S_IWUSR);
|
|
|
|
g_free(g_tlscerts_data);
|
|
|
|
}
|