diff options
author | Steffen Jaeckel <jaeckel-floss@eyet-services.de> | 2022-03-21 14:34:15 +0100 |
---|---|---|
committer | Steffen Jaeckel <jaeckel-floss@eyet-services.de> | 2022-03-22 11:34:23 +0100 |
commit | 7c56eac154927e344c4720cad059e9a9752e16d5 (patch) | |
tree | e07be4d663f7b20b73938b8c4f1f00d86b059014 /src | |
parent | 44e65f3089e49a769a0251df659ff27702417950 (diff) | |
download | profani-tty-7c56eac154927e344c4720cad059e9a9752e16d5.tar.gz |
also store PEM in `TLSCertificate`
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/config/tlscerts.c | 11 | ||||
-rw-r--r-- | src/config/tlscerts.h | 3 | ||||
-rw-r--r-- | src/xmpp/connection.c | 3 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/config/tlscerts.c b/src/config/tlscerts.c index ef70b995..8a4ed553 100644 --- a/src/config/tlscerts.c +++ b/src/config/tlscerts.c @@ -130,7 +130,7 @@ tlscerts_list(void) char* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL); TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore, - notafter, keyalg, signaturealg); + notafter, keyalg, signaturealg, NULL); free(fingerprint); free(serialnumber); @@ -154,7 +154,7 @@ tlscerts_list(void) TLSCertificate* 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) + const char* const key_alg, const char* const signature_alg, const char* const pem) { TLSCertificate* cert = calloc(1, sizeof(TLSCertificate)); @@ -183,6 +183,9 @@ tlscerts_new(const char* const fingerprint, int version, const char* const seria if (signature_alg) { cert->signature_alg = strdup(signature_alg); } + if (pem) { + cert->pem = strdup(pem); + } gchar** fields = g_strsplit(subjectname, "/", 0); for (int i = 0; i < g_strv_length(fields); i++) { @@ -322,7 +325,7 @@ tlscerts_get_trusted(const char* const fingerprint) char* signaturealg = g_key_file_get_string(tlscerts, fingerprint, "signaturealg", NULL); TLSCertificate* cert = tlscerts_new(fingerprint, version, serialnumber, subjectname, issuername, notbefore, - notafter, keyalg, signaturealg); + notafter, keyalg, signaturealg, NULL); free(serialnumber); free(subjectname); @@ -380,6 +383,8 @@ tlscerts_free(TLSCertificate* cert) free(cert->key_alg); free(cert->signature_alg); + free(cert->pem); + free(cert); } } diff --git a/src/config/tlscerts.h b/src/config/tlscerts.h index ba3b6894..c03d3b09 100644 --- a/src/config/tlscerts.h +++ b/src/config/tlscerts.h @@ -65,13 +65,14 @@ typedef struct tls_cert_t char* fingerprint; char* key_alg; char* signature_alg; + char* pem; } TLSCertificate; void tlscerts_init(void); TLSCertificate* 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); + const char* const key_alg, const char* const signature_alg, const char* const pem); void tlscerts_set_current(const char* const fp); diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index d601de22..54bb1449 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -1100,7 +1100,8 @@ _xmppcert_to_profcert(const xmpp_tlscert_t* xmpptlscert) xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_NOTBEFORE), xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_NOTAFTER), xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_KEYALG), - xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_SIGALG)); + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_SIGALG), + xmpp_tlscert_get_pem(xmpptlscert)); } static xmpp_log_t* |