Show summary of trusted certificates, add /tls cert <fingerprint>

fixes #676
This commit is contained in:
James Booth
2015-11-22 19:53:41 +00:00
parent 216493ef07
commit bf1e7efe23
7 changed files with 91 additions and 20 deletions

View File

@@ -131,6 +131,15 @@ tlscerts_list(void)
TLSCertificate *cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore,
notafter, keyalg, signaturealg);
free(fingerprint);
free(serialnumber);
free(subjectname);
free(issuername);
free(notbefore);
free(notafter);
free(keyalg);
free(signaturealg);
res = g_list_append(res, cert);
}
@@ -328,6 +337,36 @@ tlscerts_revoke(const char *const fingerprint)
return result;
}
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;
}
char*
tlscerts_complete(const char *const prefix)
{

View File

@@ -81,6 +81,8 @@ void tlscerts_add(TLSCertificate *cert);
gboolean tlscerts_revoke(const char *const fingerprint);
TLSCertificate* tlscerts_get_trusted(const char *const fingerprint);
void tlscerts_free(TLSCertificate *cert);
GList* tlscerts_list(void);