Ejemplo n.º 1
0
/* retrieves the status of a cert from the ocsp cache
 * returns CERT_UNDEFINED if no status is found
 */
static cert_status_t
get_ocsp_status(const ocsp_location_t *loc, chunk_t serialNumber
    ,time_t *nextUpdate)
{
    ocsp_certinfo_t *certinfo, **certinfop;
    bool cmp;

    /* find location */
    ocsp_location_t *location = get_ocsp_location(loc, ocsp_cache);

    if (location == NULL)
	return CERT_UNDEFINED;

    /* traverse list of certinfos in increasing order */
    certinfop = &location->certinfo;
    certinfo = *certinfop;

    while (certinfo != NULL)
    {
	cmp = cmp_chunk(serialNumber, certinfo->serialNumber);
	if (cmp <= 0)
	    break;
	certinfop = &certinfo->next;
	certinfo = *certinfop;
    }

    if (cmp == 0)
    {
	*nextUpdate = certinfo->nextUpdate;
	return certinfo->status;
    }

    return CERT_UNDEFINED;
}
Ejemplo n.º 2
0
/**
 * Retrieves the status of a cert from the ocsp cache
 * returns CERT_UNDEFINED if no status is found
 */
static cert_status_t get_ocsp_status(const ocsp_location_t *loc,
									 chunk_t serialNumber,
									 time_t *nextUpdate, time_t *revocationTime,
									 crl_reason_t *revocationReason)
{
	ocsp_certinfo_t *certinfo, **certinfop;
	int cmp = -1;

	/* find location */
	ocsp_location_t *location = get_ocsp_location(loc, ocsp_cache);

	if (location == NULL)
		return CERT_UNDEFINED;

	/* traverse list of certinfos in increasing order */
	certinfop = &location->certinfo;
	certinfo = *certinfop;

	while (certinfo)
	{
		cmp = chunk_compare(serialNumber, certinfo->serialNumber);
		if (cmp <= 0)
			break;
		certinfop = &certinfo->next;
		certinfo = *certinfop;
	}

	if (cmp == 0)
	{
		*nextUpdate = certinfo->nextUpdate;
		*revocationTime = certinfo->revocationTime;
		*revocationReason = certinfo->revocationReason;
		return certinfo->status;
	}

	return CERT_UNDEFINED;
}