diff options
author | James Booth <boothj5@gmail.com> | 2015-11-22 19:53:41 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-11-22 19:53:41 +0000 |
commit | bf1e7efe230c899535ea2dedae8255c0a09b6cc3 (patch) | |
tree | c73dde9f235226da0dcf6ef56017381dbece628b /src/config | |
parent | 216493ef07662e8f53f7c0de2391a43ef9bd3a8a (diff) | |
download | profani-tty-bf1e7efe230c899535ea2dedae8255c0a09b6cc3.tar.gz |
Show summary of trusted certificates, add /tls cert <fingerprint>
fixes #676
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/tlscerts.c | 39 | ||||
-rw-r--r-- | src/config/tlscerts.h | 2 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/config/tlscerts.c b/src/config/tlscerts.c index 321e04c7..447e57dc 100644 --- a/src/config/tlscerts.c +++ b/src/config/tlscerts.c @@ -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) { diff --git a/src/config/tlscerts.h b/src/config/tlscerts.h index d0e59218..dd827dbc 100644 --- a/src/config/tlscerts.h +++ b/src/config/tlscerts.h @@ -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); |