/**
* check the signature of an OCSP response
*/
-static bool verify_ocsp(ocsp_response_t *response, certificate_t *ca)
+static bool verify_ocsp(ocsp_response_t *response, certificate_t *ca,
+ bool cached)
{
certificate_t *issuer, *subject;
identification_t *responder;
found = TRUE;
if (lib->credmgr->issued_by(lib->credmgr, subject, issuer, NULL))
{
- DBG1(DBG_CFG, " ocsp response correctly signed by \"%Y\"",
- issuer->get_subject(issuer));
+ if (!cached)
+ {
+ DBG1(DBG_CFG, " ocsp response correctly signed by \"%Y\"",
+ issuer->get_subject(issuer));
+ }
verified = TRUE;
break;
}
found = TRUE;
if (lib->credmgr->issued_by(lib->credmgr, subject, issuer, NULL))
{
- DBG1(DBG_CFG, " ocsp response correctly signed by \"%Y\"",
- issuer->get_subject(issuer));
+ if (!cached)
+ {
+ DBG1(DBG_CFG, " ocsp response correctly signed by \"%Y\"",
+ issuer->get_subject(issuer));
+ }
verified = TRUE;
break;
}
lib->credmgr->remove_local_set(lib->credmgr, &wrapper->set);
wrapper->destroy(wrapper);
- if (!found)
+ if (!found && !cached)
{
DBG1(DBG_CFG, "ocsp response verification failed, "
"no signer certificate '%Y' found", responder);
*/
static certificate_t *get_better_ocsp(certificate_t *cand, certificate_t *best,
x509_t *subject, x509_t *issuer,
- cert_validation_t *valid, bool cache)
+ cert_validation_t *valid, bool cached)
{
ocsp_response_t *response;
time_t revocation, this_update, next_update, valid_until;
response = (ocsp_response_t*)cand;
/* check ocsp signature */
- if (!verify_ocsp(response, &issuer->interface))
+ if (!verify_ocsp(response, &issuer->interface, cached))
{
cand->destroy(cand);
return best;
default:
case VALIDATION_FAILED:
/* candidate unusable, does not contain our cert */
- DBG1(DBG_CFG, " ocsp response contains no status on our certificate");
+ if (!cached)
+ {
+ DBG1(DBG_CFG, " ocsp response contains no status on our "
+ "certificate");
+ }
cand->destroy(cand);
return best;
}
DBG1(DBG_CFG, " ocsp response is valid: until %T",
&valid_until, FALSE);
*valid = VALIDATION_GOOD;
- if (cache)
+ if (!cached)
{ /* cache non-stale only, stale certs get refetched */
lib->credmgr->cache_cert(lib->credmgr, best);
}
while (enumerator->enumerate(enumerator, ¤t))
{
current->get_ref(current);
- best = get_better_ocsp(current, best, subject, issuer, &valid, FALSE);
+ best = get_better_ocsp(current, best, subject, issuer, &valid, TRUE);
if (best && valid != VALIDATION_STALE)
{
DBG1(DBG_CFG, " using cached ocsp response");
if (current)
{
best = get_better_ocsp(current, best, subject, issuer,
- &valid, TRUE);
+ &valid, FALSE);
if (best && valid != VALIDATION_STALE)
{
break;
if (current)
{
best = get_better_ocsp(current, best, subject, issuer,
- &valid, TRUE);
+ &valid, FALSE);
if (best && valid != VALIDATION_STALE)
{
break;