diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-24 16:24:40 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-24 16:24:40 +0300 |
commit | 42bb54ff55ae6e2e2c6bf8a5581d14c1289f0234 (patch) | |
tree | 9a4cd949264e98bf47032199779ee27bd1193f58 /src/gmcerts.c | |
parent | 455a635080a1c1c4b164af3060836f0d8c1b3c1c (diff) |
SidebarWidget: List identities as sidebar items
Diffstat (limited to 'src/gmcerts.c')
-rw-r--r-- | src/gmcerts.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/gmcerts.c b/src/gmcerts.c index e13e9a8d..2624eb4d 100644 --- a/src/gmcerts.c +++ b/src/gmcerts.c | |||
@@ -125,6 +125,7 @@ static iBool isValid_GmIdentity_(const iGmIdentity *d) { | |||
125 | static void setCertificate_GmIdentity_(iGmIdentity *d, iTlsCertificate *cert) { | 125 | static void setCertificate_GmIdentity_(iGmIdentity *d, iTlsCertificate *cert) { |
126 | delete_TlsCertificate(d->cert); | 126 | delete_TlsCertificate(d->cert); |
127 | d->cert = cert; | 127 | d->cert = cert; |
128 | set_Block(&d->fingerprint, collect_Block(fingerprint_TlsCertificate(cert))); | ||
128 | } | 129 | } |
129 | 130 | ||
130 | static const iString *readFile_(const iString *path) { | 131 | static const iString *readFile_(const iString *path) { |
@@ -249,7 +250,6 @@ static void loadIdentityFromCertificate_GmCerts_(iGmCerts *d, const iString *crt | |||
249 | iGmIdentity *ident = findIdentity_GmCerts_(d, finger); | 250 | iGmIdentity *ident = findIdentity_GmCerts_(d, finger); |
250 | if (!ident) { | 251 | if (!ident) { |
251 | ident = new_GmIdentity(); | 252 | ident = new_GmIdentity(); |
252 | set_Block(&ident->fingerprint, finger); | ||
253 | iDate today; | 253 | iDate today; |
254 | initCurrent_Date(&today); | 254 | initCurrent_Date(&today); |
255 | set_String(&ident->notes, collect_String(format_Date(&today, "Imported on %b %d, %Y"))); | 255 | set_String(&ident->notes, collect_String(format_Date(&today, "Imported on %b %d, %Y"))); |
@@ -387,9 +387,9 @@ iGmIdentity *newIdentity_GmCerts(iGmCerts *d, int flags, iDate validUntil, const | |||
387 | const iTlsCertificateName names[] = { | 387 | const iTlsCertificateName names[] = { |
388 | { issuerCommonName_TlsCertificateNameType, collectNewCStr_String("fi.skyjake.Lagrange") }, | 388 | { issuerCommonName_TlsCertificateNameType, collectNewCStr_String("fi.skyjake.Lagrange") }, |
389 | { subjectCommonName_TlsCertificateNameType, commonName }, | 389 | { subjectCommonName_TlsCertificateNameType, commonName }, |
390 | { subjectUserId_TlsCertificateNameType, userId }, | 390 | { subjectUserId_TlsCertificateNameType, !isEmpty_String(userId) ? userId : NULL }, |
391 | { subjectOrganization_TlsCertificateNameType, org }, | 391 | { subjectOrganization_TlsCertificateNameType, !isEmpty_String(org) ? org : NULL }, |
392 | { subjectCountry_TlsCertificateNameType, country }, | 392 | { subjectCountry_TlsCertificateNameType, !isEmpty_String(country) ? country : NULL }, |
393 | { 0, NULL } | 393 | { 0, NULL } |
394 | }; | 394 | }; |
395 | iGmIdentity *id = new_GmIdentity(); | 395 | iGmIdentity *id = new_GmIdentity(); |
@@ -398,17 +398,22 @@ iGmIdentity *newIdentity_GmCerts(iGmCerts *d, int flags, iDate validUntil, const | |||
398 | if (~flags & temporary_GmIdentityFlag) { | 398 | if (~flags & temporary_GmIdentityFlag) { |
399 | const char *finger = cstrCollect_String(hexEncode_Block(&id->fingerprint)); | 399 | const char *finger = cstrCollect_String(hexEncode_Block(&id->fingerprint)); |
400 | if (!writeTextFile_( | 400 | if (!writeTextFile_( |
401 | collect_String(concatCStr_Path(&d->saveDir, format_CStr("%s.crt", finger))), | 401 | collect_String(concatCStr_Path(&d->saveDir, format_CStr("idents/%s.crt", finger))), |
402 | collect_String(pem_TlsCertificate(id->cert)))) { | 402 | collect_String(pem_TlsCertificate(id->cert)))) { |
403 | delete_GmIdentity(id); | 403 | delete_GmIdentity(id); |
404 | return NULL; | 404 | return NULL; |
405 | } | 405 | } |
406 | if (!writeTextFile_( | 406 | if (!writeTextFile_( |
407 | collect_String(concatCStr_Path(&d->saveDir, format_CStr("%s.key", finger))), | 407 | collect_String(concatCStr_Path(&d->saveDir, format_CStr("idents/%s.key", finger))), |
408 | collect_String(privateKeyPem_TlsCertificate(id->cert)))) { | 408 | collect_String(privateKeyPem_TlsCertificate(id->cert)))) { |
409 | delete_GmIdentity(id); | 409 | delete_GmIdentity(id); |
410 | return NULL; | 410 | return NULL; |
411 | } | 411 | } |
412 | } | 412 | } |
413 | pushBack_PtrArray(&d->idents, id); | ||
413 | return id; | 414 | return id; |
414 | } | 415 | } |
416 | |||
417 | const iPtrArray *identities_GmCerts(const iGmCerts *d) { | ||
418 | return &d->idents; | ||
419 | } | ||