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

Function status_get_md_json

modules/md/md_status.c:251–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251static apr_status_t status_get_md_json(md_json_t **pjson, const md_t *md,
252 md_reg_t *reg, md_ocsp_reg_t *ocsp,
253 int with_logs, apr_pool_t *p)
254{
255 md_json_t *mdj, *certsj, *jobj = NULL;
256 int renew;
257 const md_pubcert_t *pubcert;
258 const md_cert_t *cert = NULL;
259 apr_array_header_t *certs;
260 apr_status_t rv = APR_SUCCESS;
261 apr_time_t renew_at;
262 int i;
263
264 mdj = md_to_public_json(md, p);
265 certs = apr_array_make(p, 5, sizeof(md_cert_t*));
266 for (i = 0; i < get_cert_count(md, 0); ++i) {
267 cert = NULL;
268 if (APR_SUCCESS == md_reg_get_pubcert(&pubcert, reg, md, i, p)) {
269 cert = APR_ARRAY_IDX(pubcert->certs, 0, const md_cert_t*);
270 }
271 APR_ARRAY_PUSH(certs, const md_cert_t*) = cert;
272 }
273
274 rv = status_get_certs_json(&certsj, certs, 0, md, reg, ocsp, with_logs, p);
275 if (APR_SUCCESS != rv) goto leave;
276 md_json_setj(certsj, mdj, MD_KEY_CERT, NULL);
277
278 renew_at = md_reg_renew_at(reg, md, p);
279 if (renew_at > 0) {
280 md_json_set_time(renew_at, mdj, MD_KEY_RENEW_AT, NULL);
281 }
282
283 md_json_setb(md->stapling, mdj, MD_KEY_STAPLING, NULL);
284 md_json_setb(md->watched, mdj, MD_KEY_WATCHED, NULL);
285
286 renew = FALSE;
287 rv = job_loadj(&jobj, MD_SG_STAGING, md->name, reg, with_logs, p);
288 if (rv == APR_SUCCESS)
289 renew = TRUE;
290 else if (APR_STATUS_IS_ENOENT(rv)) {
291 rv = APR_SUCCESS;
292 renew = md_reg_should_renew(reg, md, p);
293 }
294 else
295 goto leave;
296
297 if (renew) {
298 md_json_setb(renew, mdj, MD_KEY_RENEW, NULL);
299 if (jobj) {
300 if (APR_SUCCESS == get_staging_certs_json(&certsj, md, reg, p)) {
301 md_json_setj(certsj, jobj, MD_KEY_CERT, NULL);
302 }
303 md_json_setj(jobj, mdj, MD_KEY_RENEWAL, NULL);
304 }
305 }
306
307leave:
308 if (APR_SUCCESS != rv) {

Callers 2

md_status_get_md_jsonFunction · 0.85
md_status_get_jsonFunction · 0.85

Calls 12

md_to_public_jsonFunction · 0.85
md_reg_get_pubcertFunction · 0.85
status_get_certs_jsonFunction · 0.85
md_json_setjFunction · 0.85
md_reg_renew_atFunction · 0.85
md_json_set_timeFunction · 0.85
md_json_setbFunction · 0.85
md_reg_should_renewFunction · 0.85
get_staging_certs_jsonFunction · 0.85
md_json_setlFunction · 0.85
get_cert_countFunction · 0.70
job_loadjFunction · 0.70

Tested by

no test coverage detected