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

Function md_to_json

modules/md/md_core.c:270–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268/* format conversion */
269
270md_json_t *md_to_json(const md_t *md, apr_pool_t *p)
271{
272 md_json_t *json = md_json_create(p);
273 if (json) {
274 apr_array_header_t *domains = md_array_str_compact(p, md->domains, 0);
275 md_json_sets(md->name, json, MD_KEY_NAME, NULL);
276 md_json_setsa(domains, json, MD_KEY_DOMAINS, NULL);
277 md_json_setsa(md->contacts, json, MD_KEY_CONTACTS, NULL);
278 md_json_setl(md->transitive, json, MD_KEY_TRANSITIVE, NULL);
279 md_json_sets(md->ca_account, json, MD_KEY_CA, MD_KEY_ACCOUNT, NULL);
280 md_json_sets(md->ca_proto, json, MD_KEY_CA, MD_KEY_PROTO, NULL);
281 md_json_sets(md->ca_effective, json, MD_KEY_CA, MD_KEY_URL, NULL);
282 if (md->ca_urls && !apr_is_empty_array(md->ca_urls)) {
283 md_json_setsa(md->ca_urls, json, MD_KEY_CA, MD_KEY_URLS, NULL);
284 }
285 md_json_sets(md->ca_agreement, json, MD_KEY_CA, MD_KEY_AGREEMENT, NULL);
286 if (!md_pkeys_spec_is_empty(md->pks)) {
287 md_json_setj(md_pkeys_spec_to_json(md->pks, p), json, MD_KEY_PKEY, NULL);
288 }
289 md_json_setl(md->state, json, MD_KEY_STATE, NULL);
290 if (md->state_descr)
291 md_json_sets(md->state_descr, json, MD_KEY_STATE_DESCR, NULL);
292 md_json_setl(md->renew_mode, json, MD_KEY_RENEW_MODE, NULL);
293 if (md->renew_window)
294 md_json_sets(md_timeslice_format(md->renew_window, p), json, MD_KEY_RENEW_WINDOW, NULL);
295 if (md->warn_window)
296 md_json_sets(md_timeslice_format(md->warn_window, p), json, MD_KEY_WARN_WINDOW, NULL);
297 if (md->ca_challenges && md->ca_challenges->nelts > 0) {
298 apr_array_header_t *na;
299 na = md_array_str_compact(p, md->ca_challenges, 0);
300 md_json_setsa(na, json, MD_KEY_CA, MD_KEY_CHALLENGES, NULL);
301 }
302 switch (md->require_https) {
303 case MD_REQUIRE_TEMPORARY:
304 md_json_sets(MD_KEY_TEMPORARY, json, MD_KEY_REQUIRE_HTTPS, NULL);
305 break;
306 case MD_REQUIRE_PERMANENT:
307 md_json_sets(MD_KEY_PERMANENT, json, MD_KEY_REQUIRE_HTTPS, NULL);
308 break;
309 default:
310 break;
311 }
312 md_json_setb(md->must_staple > 0, json, MD_KEY_MUST_STAPLE, NULL);
313 md_json_setsa(md->acme_tls_1_domains, json, MD_KEY_PROTO, MD_KEY_ACME_TLS_1, NULL);
314 if (md->cert_files) md_json_setsa(md->cert_files, json, MD_KEY_CERT_FILES, NULL);
315 if (md->pkey_files) md_json_setsa(md->pkey_files, json, MD_KEY_PKEY_FILES, NULL);
316 md_json_setb(md->stapling > 0, json, MD_KEY_STAPLING, NULL);
317 if (md->dns01_cmd) md_json_sets(md->dns01_cmd, json, MD_KEY_CMD_DNS01, NULL);
318 if (md->ca_eab_kid && strcmp("none", md->ca_eab_kid)) {
319 md_json_sets(md->ca_eab_kid, json, MD_KEY_EAB, MD_KEY_KID, NULL);
320 if (md->ca_eab_hmac) md_json_sets(md->ca_eab_hmac, json, MD_KEY_EAB, MD_KEY_HMAC, NULL);
321 }
322 if (md->profile) md_json_sets(md->profile, json, MD_KEY_PROFILE, NULL);
323 md_json_setb(md->profile_mandatory > 0, json, MD_KEY_PROFILE_MANDATORY, NULL);
324 md_json_setb(md->ari_renewals > 0, json, MD_KEY_ARI_RENEWALS, NULL);
325 return json;
326 }
327 return NULL;

Callers 2

md_to_public_jsonFunction · 0.85
p_saveFunction · 0.85

Calls 10

md_json_createFunction · 0.85
md_array_str_compactFunction · 0.85
md_json_setsFunction · 0.85
md_json_setsaFunction · 0.85
md_json_setlFunction · 0.85
md_pkeys_spec_is_emptyFunction · 0.85
md_json_setjFunction · 0.85
md_pkeys_spec_to_jsonFunction · 0.85
md_timeslice_formatFunction · 0.85
md_json_setbFunction · 0.85

Tested by

no test coverage detected