MCPcopy Create free account
hub / github.com/apache/httpd / md_get_challenge_cert

Function md_get_challenge_cert

modules/md/mod_md.c:1299–1342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1297}
1298
1299static int md_get_challenge_cert(conn_rec *c, const char *servername,
1300 md_srv_conf_t *sc,
1301 md_pkey_type_t key_type,
1302 const char **pcert_pem,
1303 const char **pkey_pem)
1304{
1305 apr_status_t rv = APR_ENOENT;
1306 int i;
1307 char *cert_name, *pkey_name;
1308 const char *cert_pem, *key_pem;
1309 md_store_t *store = md_reg_store_get(sc->mc->reg);
1310 md_pkey_spec_t *key_spec;
1311
1312 for (i = 0; i < md_pkeys_spec_count(sc->pks); i++) {
1313 key_spec = md_pkeys_spec_get(sc->pks, i);
1314 if (key_spec->type != key_type)
1315 continue;
1316
1317 tls_alpn01_fnames(c->pool, key_spec, &pkey_name, &cert_name);
1318
1319 rv = md_store_load(store, MD_SG_CHALLENGES, servername, cert_name, MD_SV_TEXT,
1320 (void**)&cert_pem, c->pool);
1321 ap_log_cerror(APLOG_MARK, APLOG_TRACE1, rv, c,
1322 "Load challenge: cert %s", cert_name);
1323 if (APR_STATUS_IS_ENOENT(rv)) continue;
1324 if (APR_SUCCESS != rv) goto cleanup;
1325
1326 rv = md_store_load(store, MD_SG_CHALLENGES, servername, pkey_name, MD_SV_TEXT,
1327 (void**)&key_pem, c->pool);
1328 ap_log_cerror(APLOG_MARK, APLOG_TRACE1, rv, c,
1329 "Load challenge: key %s", pkey_name);
1330 if (APR_STATUS_IS_ENOENT(rv)) continue;
1331 if (APR_SUCCESS != rv) goto cleanup;
1332
1333 ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c,
1334 "Found challenge: cert %s, key %s for %s",
1335 cert_name, pkey_name, servername);
1336 *pcert_pem = cert_pem;
1337 *pkey_pem = key_pem;
1338 return OK;
1339 }
1340cleanup:
1341 return DECLINED;
1342}
1343
1344static int md_answer_challenge(conn_rec *c, const char *servername,
1345 const char **pcert_pem, const char **pkey_pem)

Callers 1

md_answer_challengeFunction · 0.85

Calls 5

md_reg_store_getFunction · 0.85
md_pkeys_spec_countFunction · 0.85
md_pkeys_spec_getFunction · 0.85
tls_alpn01_fnamesFunction · 0.85
md_store_loadFunction · 0.85

Tested by

no test coverage detected