Example #1
0
static NSSCertificate *
get_best_temp_or_perm(NSSCertificate *ct, NSSCertificate *cp)
{
    NSSUsage usage;
    NSSCertificate *arr[3];
    if (!ct) {
        return nssCertificate_AddRef(cp);
    } else if (!cp) {
        return nssCertificate_AddRef(ct);
    }
    arr[0] = ct;
    arr[1] = cp;
    arr[2] = NULL;
    usage.anyUsage = PR_TRUE;
    return nssCertificateArray_FindBestCertificate(arr, NULL, &usage, NULL);
}
Example #2
0
/* Caller holds store->lock */
static NSSCertificate *
nssCertStore_FindCertByIssuerAndSerialNumberLocked (
  nssCertificateStore *store,
  NSSDER *issuer,
  NSSDER *serial
)
{
    certificate_hash_entry *entry;
    NSSCertificate *rvCert = NULL;
    NSSCertificate index;

    index.issuer = *issuer;
    index.serial = *serial;
    entry = (certificate_hash_entry *)
                           nssHash_Lookup(store->issuer_and_serial, &index);
    if (entry) {
	rvCert = nssCertificate_AddRef(entry->cert);
    }
    return rvCert;
}
Example #3
0
NSS_IMPLEMENT NSSCertificate *
nssCertificateStore_FindOrAdd (
  nssCertificateStore *store,
  NSSCertificate *c
)
{
    PRStatus nssrv;
    NSSCertificate *rvCert = NULL;

    PZ_Lock(store->lock);
    rvCert = nssCertStore_FindCertByIssuerAndSerialNumberLocked(
					   store, &c->issuer, &c->serial);
    if (!rvCert) {
	nssrv = nssCertificateStore_AddLocked(store, c);
	if (PR_SUCCESS == nssrv) {
	    rvCert = nssCertificate_AddRef(c);
	}
    }
    PZ_Unlock(store->lock);
    return rvCert;
}
Example #4
0
static PRStatus add_ref_callback(NSSCertificate *c, void *a)
{
    nssCertificate_AddRef(c);
    return PR_SUCCESS;
}
Example #5
0
static void cert_iter(const void *k, void *v, void *a)
{
    nssList *certList = (nssList *)a;
    NSSCertificate *c = (NSSCertificate *)k;
    nssList_Add(certList, nssCertificate_AddRef(c));
}