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

Function state_init

modules/md/md_reg.c:227–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225/* state assessment */
226
227static apr_status_t state_init(md_reg_t *reg, apr_pool_t *p, md_t *md)
228{
229 md_state_t state = MD_S_COMPLETE;
230 const char *state_descr = NULL;
231 const md_pubcert_t *pub;
232 const md_cert_t *cert;
233 const md_pkey_spec_t *spec;
234 apr_status_t rv = APR_SUCCESS;
235 int i, is_static = (md->cert_files && md->cert_files->nelts);
236
237 if (md->renew_window == NULL) md->renew_window = reg->renew_window;
238 if (md->warn_window == NULL) md->warn_window = reg->warn_window;
239
240 if (is_static) {
241 if (md->renew_mode == MD_RENEW_AUTO)
242 md->renew_mode = MD_RENEW_MANUAL;
243 }
244
245 if (md->domains && md->domains->pool != p) {
246 md_log_perror(MD_LOG_MARK, MD_LOG_ERR, 0, p,
247 "md{%s}: state_init called with foreign pool", md->name);
248 }
249
250 for (i = 0; i < md_cert_count(md); ++i) {
251 spec = md_pkeys_spec_get(md->pks, i);
252 md_log_perror(MD_LOG_MARK, MD_LOG_TRACE2, rv, p,
253 "md{%s}: check cert %s", md->name, md_pkey_spec_name(spec));
254 rv = md_reg_get_pubcert(&pub, reg, md, i, p);
255 if (APR_SUCCESS == rv) {
256 cert = APR_ARRAY_IDX(pub->certs, 0, const md_cert_t*);
257 if (!md_is_covered_by_alt_names(md, pub->alt_names)) {
258 state = MD_S_INCOMPLETE;
259 state_descr = apr_psprintf(p, "certificate(%s) does not cover all domains.",
260 md_pkey_spec_name(spec));
261 goto cleanup;
262 }
263 if (!md->must_staple != !md_cert_must_staple(cert)) {
264 state = MD_S_INCOMPLETE;
265 state_descr = apr_psprintf(p, "'must-staple' is%s requested, but "
266 "certificate(%s) has it%s enabled.",
267 md->must_staple? "" : " not",
268 md_pkey_spec_name(spec),
269 !md->must_staple? "" : " not");
270 goto cleanup;
271 }
272 md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, rv, p, "md{%s}: certificate(%d) is ok",
273 md->name, i);
274 }
275 else if (APR_STATUS_IS_ENOENT(rv)) {
276 state = MD_S_INCOMPLETE;
277 state_descr = apr_psprintf(p, "certificate(%s) is missing",
278 md_pkey_spec_name(spec));
279 rv = APR_SUCCESS;
280 goto cleanup;
281 }
282 else {
283 state = MD_S_ERROR;
284 state_descr = "error initializing";

Callers 7

reg_md_iterFunction · 0.85
md_reg_getFunction · 0.85
md_reg_findFunction · 0.85
md_reg_find_overlapFunction · 0.85
p_md_addFunction · 0.85
p_md_updateFunction · 0.85
md_reg_sync_finishFunction · 0.85

Calls 7

md_log_perrorFunction · 0.85
md_cert_countFunction · 0.85
md_pkeys_spec_getFunction · 0.85
md_pkey_spec_nameFunction · 0.85
md_reg_get_pubcertFunction · 0.85
md_cert_must_stapleFunction · 0.85

Tested by

no test coverage detected