summaryrefslogtreecommitdiff
path: root/src/gmcerts.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmcerts.c')
-rw-r--r--src/gmcerts.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gmcerts.c b/src/gmcerts.c
index 27b226a0..f7475348 100644
--- a/src/gmcerts.c
+++ b/src/gmcerts.c
@@ -381,6 +381,7 @@ iBool checkTrust_GmCerts(iGmCerts *d, iRangecc domain, const iTlsCertificate *ce
381 if (!verifyDomain_TlsCertificate(cert, domain)) { 381 if (!verifyDomain_TlsCertificate(cert, domain)) {
382 return iFalse; 382 return iFalse;
383 } 383 }
384 /* TODO: Could call setTrusted_GmCerts() instead of duplicating the trust-setting. */
384 /* Good certificate. If not already trusted, add it now. */ 385 /* Good certificate. If not already trusted, add it now. */
385 iString *key = newRange_String(domain); 386 iString *key = newRange_String(domain);
386 iDate until; 387 iDate until;
@@ -415,6 +416,22 @@ iBool checkTrust_GmCerts(iGmCerts *d, iRangecc domain, const iTlsCertificate *ce
415 return iTrue; 416 return iTrue;
416} 417}
417 418
419void setTrusted_GmCerts(iGmCerts *d, iRangecc domain, const iBlock *fingerprint,
420 const iDate *validUntil) {
421 iString *key = collect_String(newRange_String(domain));
422 lock_Mutex(d->mtx);
423 iTrustEntry *trust = value_StringHash(d->trusted, key);
424 if (trust) {
425 init_Time(&trust->validUntil, validUntil);
426 set_Block(&trust->fingerprint, fingerprint);
427 }
428 else {
429 insert_StringHash(d->trusted, key, iClob(trust = new_TrustEntry(fingerprint, validUntil)));
430 }
431 save_GmCerts_(d);
432 unlock_Mutex(d->mtx);
433}
434
418iGmIdentity *identity_GmCerts(iGmCerts *d, unsigned int id) { 435iGmIdentity *identity_GmCerts(iGmCerts *d, unsigned int id) {
419 return at_PtrArray(&d->idents, id); 436 return at_PtrArray(&d->idents, id);
420} 437}