diff options
Diffstat (limited to 'lib/libtls/tls_ocsp.c')
-rw-r--r-- | lib/libtls/tls_ocsp.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/libtls/tls_ocsp.c b/lib/libtls/tls_ocsp.c index a8835edc8ff..307ae842b8a 100644 --- a/lib/libtls/tls_ocsp.c +++ b/lib/libtls/tls_ocsp.c @@ -101,23 +101,24 @@ tls_ocsp_fill_info(struct tls *ctx, int response_status, int cert_status, tls_ocsp_asn1_parse_time(ctx, revtime, &info->revocation_time) != 0) { tls_set_error(ctx, "unable to parse revocation time in OCSP reply"); - goto error; + goto err; } if (thisupd != NULL && tls_ocsp_asn1_parse_time(ctx, thisupd, &info->this_update) != 0) { tls_set_error(ctx, "unable to parse this update time in OCSP reply"); - goto error; + goto err; } if (nextupd != NULL && tls_ocsp_asn1_parse_time(ctx, nextupd, &info->next_update) != 0) { tls_set_error(ctx, "unable to parse next update time in OCSP reply"); - goto error; + goto err; } ctx->ocsp->ocsp_result = info; return 0; - error: + + err: free(info); return -1; } @@ -162,32 +163,32 @@ tls_ocsp_setup_from_peer(struct tls *ctx) STACK_OF(OPENSSL_STRING) *ocsp_urls = NULL; if ((ocsp = tls_ocsp_new()) == NULL) - goto failed; + goto err; /* steal state from ctx struct */ ocsp->main_cert = SSL_get_peer_certificate(ctx->ssl_conn); ocsp->extra_certs = SSL_get_peer_cert_chain(ctx->ssl_conn); if (ocsp->main_cert == NULL) { tls_set_errorx(ctx, "no peer certificate for OCSP"); - goto failed; + goto err; } ocsp_urls = X509_get1_ocsp(ocsp->main_cert); if (ocsp_urls == NULL) { tls_set_errorx(ctx, "no OCSP URLs in peer certificate"); - goto failed; + goto err; } ocsp->ocsp_url = strdup(sk_OPENSSL_STRING_value(ocsp_urls, 0)); if (ocsp->ocsp_url == NULL) { tls_set_errorx(ctx, "out of memory"); - goto failed; + goto err; } X509_email_free(ocsp_urls); return ocsp; - failed: + err: tls_ocsp_free(ocsp); X509_email_free(ocsp_urls); return NULL; @@ -206,7 +207,7 @@ tls_ocsp_verify_response(struct tls *ctx, OCSP_RESPONSE *resp) if ((br = OCSP_response_get1_basic(resp)) == NULL) { tls_set_errorx(ctx, "cannot load ocsp reply"); - goto error; + goto err; } /* @@ -219,7 +220,7 @@ tls_ocsp_verify_response(struct tls *ctx, OCSP_RESPONSE *resp) if (OCSP_basic_verify(br, ctx->ocsp->extra_certs, SSL_CTX_get_cert_store(ctx->ssl_ctx), flags) != 1) { tls_set_error(ctx, "ocsp verify failed"); - goto error; + goto err; } /* signature OK, look inside */ @@ -227,43 +228,43 @@ tls_ocsp_verify_response(struct tls *ctx, OCSP_RESPONSE *resp) if (response_status != OCSP_RESPONSE_STATUS_SUCCESSFUL) { tls_set_errorx(ctx, "ocsp verify failed: response - %s", OCSP_response_status_str(response_status)); - goto error; + goto err; } cid = tls_ocsp_get_certid(ctx->ocsp->main_cert, ctx->ocsp->extra_certs, ctx->ssl_ctx); if (cid == NULL) { tls_set_errorx(ctx, "ocsp verify failed: no issuer cert"); - goto error; + goto err; } if (OCSP_resp_find_status(br, cid, &cert_status, &crl_reason, &revtime, &thisupd, &nextupd) != 1) { tls_set_errorx(ctx, "ocsp verify failed: no result for cert"); - goto error; + goto err; } if (OCSP_check_validity(thisupd, nextupd, JITTER_SEC, MAXAGE_SEC) != 1) { tls_set_errorx(ctx, "ocsp verify failed: ocsp response not current"); - goto error; + goto err; } if (tls_ocsp_fill_info(ctx, response_status, cert_status, crl_reason, revtime, thisupd, nextupd) != 0) - goto error; + goto err; /* finally can look at status */ if (cert_status != V_OCSP_CERTSTATUS_GOOD && cert_status != V_OCSP_CERTSTATUS_UNKNOWN) { tls_set_errorx(ctx, "ocsp verify failed: revoked cert - %s", OCSP_crl_reason_str(crl_reason)); - goto error; + goto err; } ret = 0; - error: + err: sk_X509_free(combined); OCSP_CERTID_free(cid); OCSP_BASICRESP_free(br); |