static PRStatus remove_subject_entry ( nssTDCertificateCache *cache, NSSCertificate *cert, nssList **subjectList, NSSUTF8 **nickname, NSSArena **arena ) { PRStatus nssrv; cache_entry *ce; *subjectList = NULL; *arena = NULL; /* Get the subject list for the cert's subject */ ce = (cache_entry *)nssHash_Lookup(cache->subject, &cert->subject); if (ce) { /* Remove the cert from the subject hash */ nssList_Remove(ce->entry.list, cert); *subjectList = ce->entry.list; *nickname = ce->nickname; *arena = ce->arena; nssrv = PR_SUCCESS; #ifdef DEBUG_CACHE log_cert_ref("removed cert", cert); log_item_dump("from subject list", &cert->subject); #endif } else { nssrv = PR_FAILURE; } return nssrv; }
static PRStatus remove_issuer_and_serial_entry( nssTDCertificateCache *cache, NSSCertificate *cert) { /* Remove the cert from the issuer/serial hash */ nssHash_Remove(cache->issuerAndSN, cert); #ifdef DEBUG_CACHE log_cert_ref("removed issuer/sn", cert); #endif return PR_SUCCESS; }
NSS_IMPLEMENT void nssTrustDomain_RemoveCertFromCacheLOCKED ( NSSTrustDomain *td, NSSCertificate *cert ) { nssList *subjectList; cache_entry *ce; NSSArena *arena; NSSUTF8 *nickname; #ifdef DEBUG_CACHE log_cert_ref("attempt to remove cert", cert); #endif ce = (cache_entry *)nssHash_Lookup(td->cache->issuerAndSN, cert); if (!ce || ce->entry.cert != cert) { /* If it's not in the cache, or a different cert is (this is really * for safety reasons, though it shouldn't happen), do nothing */ #ifdef DEBUG_CACHE PR_LOG(s_log, PR_LOG_DEBUG, ("but it wasn't in the cache")); #endif return; } (void)remove_issuer_and_serial_entry(td->cache, cert); (void)remove_subject_entry(td->cache, cert, &subjectList, &nickname, &arena); if (nssList_Count(subjectList) == 0) { (void)remove_nickname_entry(td->cache, nickname, subjectList); (void)remove_email_entry(td->cache, cert, subjectList); (void)nssList_Destroy(subjectList); nssHash_Remove(td->cache->subject, &cert->subject); /* there are no entries left for this subject, free the space used * for both the nickname and subject entries */ if (arena) { nssArena_Destroy(arena); } } }