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

Function md_ocsp_status_hook

modules/md/mod_md_status.c:864–928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

862}
863
864int md_ocsp_status_hook(request_rec *r, int flags)
865{
866 const md_srv_conf_t *sc;
867 const md_mod_conf_t *mc;
868 int i;
869 status_ctx ctx;
870 md_json_t *jstatus, *jstock;
871
872 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "server-status for ocsp stapling, start");
873 sc = ap_get_module_config(r->server->module_config, &md_module);
874 if (!sc) return DECLINED;
875 mc = sc->mc;
876 if (!mc || !mc->server_status_enabled) return DECLINED;
877
878 ctx.p = r->pool;
879 ctx.mc = mc;
880 ctx.bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
881 ctx.flags = flags;
882 ctx.prefix = "ManagedStaplings";
883 ctx.separator = " ";
884
885 if (!HTML_STATUS(&ctx)) {
886 int total = 0, good = 0, revoked = 0, unknown = 0;
887 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "no-html ocsp stapling status summary");
888 if (md_ocsp_count(mc->ocsp) > 0) {
889 md_ocsp_get_summary(&jstock, mc->ocsp, r->pool);
890 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "got JSON ocsp stapling status summary");
891 total = (int)md_json_getl(jstock, MD_KEY_TOTAL, NULL);
892 good = (int)md_json_getl(jstock, MD_KEY_GOOD, NULL);
893 revoked = (int)md_json_getl(jstock, MD_KEY_REVOKED, NULL);
894 unknown = (int)md_json_getl(jstock, MD_KEY_UNKNOWN, NULL);
895 }
896 apr_brigade_printf(ctx.bb, NULL, NULL, "%sTotal: %d\n", ctx.prefix, total);
897 apr_brigade_printf(ctx.bb, NULL, NULL, "%sOK: %d\n", ctx.prefix, good);
898 apr_brigade_printf(ctx.bb, NULL, NULL, "%sRenew: %d\n", ctx.prefix, revoked);
899 apr_brigade_printf(ctx.bb, NULL, NULL, "%sErrored: %d\n", ctx.prefix, unknown);
900 }
901 if (md_ocsp_count(mc->ocsp) > 0) {
902 md_ocsp_get_status_all(&jstatus, mc->ocsp, r->pool);
903 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "got JSON ocsp stapling status");
904 if (HTML_STATUS(&ctx)) {
905 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "html ocsp stapling status table");
906 apr_brigade_puts(ctx.bb, NULL, NULL,
907 "<hr>\n<h3>Managed Staplings</h3>\n<table class='md_ocsp_status'><thead><tr>\n");
908 for (i = 0; i < (int)(sizeof(ocsp_status_infos)/sizeof(ocsp_status_infos[0])); ++i) {
909 si_add_header(&ctx, &ocsp_status_infos[i]);
910 }
911 apr_brigade_puts(ctx.bb, NULL, NULL, "</tr>\n</thead><tbody>");
912 }
913 else {
914 ctx.prefix = "ManagedStapling";
915 }
916 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "iterating JSON ocsp stapling status");
917 md_json_itera(add_ocsp_row, &ctx, jstatus, MD_KEY_OCSPS, NULL);
918 if (HTML_STATUS(&ctx)) {
919 apr_brigade_puts(ctx.bb, NULL, NULL, "</td></tr>\n</tbody>\n</table>\n");
920 }
921 }

Callers

nothing calls this directly

Calls 8

ap_get_module_configFunction · 0.85
md_ocsp_countFunction · 0.85
md_ocsp_get_summaryFunction · 0.85
md_json_getlFunction · 0.85
md_ocsp_get_status_allFunction · 0.85
si_add_headerFunction · 0.85
md_json_iteraFunction · 0.85
ap_pass_brigadeFunction · 0.85

Tested by

no test coverage detected