Changeset bdd10be in mod_gnutls


Ignore:
Timestamp:
Jan 11, 2020, 10:40:01 AM (3 years ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, main, master, proxy-ticket
Children:
e798149
Parents:
a8374f7
git-author:
Fiona Klute <fiona.klute@…> (01/11/20 10:24:59)
git-committer:
Fiona Klute <fiona.klute@…> (01/11/20 10:40:01)
Message:

mgs_create_ocsp_request: Require explicit struct mgs_ocsp_data

This means the OCSP request gets built from the passed data, instead
of assuming the request will be for the server certificate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnutls_ocsp.c

    ra8374f7 rbdd10be  
    150150 * if not NULL).
    151151 *
    152  * Returns GNUTLS_E_SUCCESS, or a GnuTLS error code.
     152 * @param s server reference for logging
     153 *
     154 * @return GNUTLS_E_SUCCESS, or a GnuTLS error code.
    153155 */
    154 static int mgs_create_ocsp_request(server_rec *s, gnutls_datum_t *req,
    155                             gnutls_datum_t *nonce)
    156     __attribute__((nonnull(1, 2)));
    157 static int mgs_create_ocsp_request(server_rec *s, gnutls_datum_t *req,
    158                             gnutls_datum_t *nonce)
    159 {
    160     mgs_srvconf_rec *sc = (mgs_srvconf_rec *)
    161         ap_get_module_config(s->module_config, &gnutls_module);
    162 
     156static int mgs_create_ocsp_request(server_rec *s,
     157                                   struct mgs_ocsp_data *req_data,
     158                                   gnutls_datum_t *req,
     159                                   gnutls_datum_t *nonce)
     160    __attribute__((nonnull(1, 3)));
     161static int mgs_create_ocsp_request(server_rec *s,
     162                                   struct mgs_ocsp_data *req_data,
     163                                   gnutls_datum_t *req,
     164                                   gnutls_datum_t *nonce)
     165{
    163166    gnutls_ocsp_req_t r;
    164167    int ret = gnutls_ocsp_req_init(&r);
     
    171174    }
    172175
     176    /* issuer is set to a reference, so musn't be cleaned up */
     177    gnutls_x509_crt_t issuer;
     178    ret = gnutls_x509_trust_list_get_issuer(*req_data->trust, req_data->cert,
     179                                            &issuer, 0);
     180    if (ret != GNUTLS_E_SUCCESS)
     181    {
     182        ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
     183                     "Could not get issuer from trust list: %s (%d)",
     184                     gnutls_strerror(ret), ret);
     185        gnutls_ocsp_req_deinit(r);
     186        return ret;
     187    }
     188
    173189    /* GnuTLS doc says that the digest is "normally"
    174190     * GNUTLS_DIG_SHA1. */
    175191    ret = gnutls_ocsp_req_add_cert(r, GNUTLS_DIG_SHA256,
    176                                    sc->certs_x509_crt_chain[1],
    177                                    sc->certs_x509_crt_chain[0]);
     192                                   issuer, req_data->cert);
    178193
    179194    if (ret != GNUTLS_E_SUCCESS)
     
    673688    {
    674689        gnutls_datum_t req;
    675         int ret = mgs_create_ocsp_request(s, &req, &nonce);
     690        int ret = mgs_create_ocsp_request(s, sc->ocsp, &req, &nonce);
    676691        if (ret == GNUTLS_E_SUCCESS)
    677692        {
Note: See TracChangeset for help on using the changeset viewer.