| 70 | }; |
| 71 | |
| 72 | static void process_drive_job(md_renew_ctx_t *dctx, md_job_t *job, apr_pool_t *ptemp) |
| 73 | { |
| 74 | const md_t *md; |
| 75 | md_result_t *result = NULL; |
| 76 | apr_status_t rv; |
| 77 | |
| 78 | md_job_load(job); |
| 79 | /* Evaluate again on loaded value. Values will change when watchdog switches child process */ |
| 80 | if (apr_time_now() < job->next_run) return; |
| 81 | |
| 82 | job->next_run = 0; |
| 83 | if (job->finished && job->notified_renewed) { |
| 84 | /* finished and notification handled, nothing to do. */ |
| 85 | goto leave; |
| 86 | } |
| 87 | |
| 88 | md = md_get_by_name(dctx->mc->mds, job->mdomain); |
| 89 | AP_DEBUG_ASSERT(md); |
| 90 | |
| 91 | result = md_result_md_make(ptemp, md->name); |
| 92 | if (job->last_result) md_result_assign(result, job->last_result); |
| 93 | |
| 94 | if (md->state == MD_S_MISSING_INFORMATION) { |
| 95 | /* Missing information, this will not change until configuration |
| 96 | * is changed and server reloaded. */ |
| 97 | job->fatal_error = 1; |
| 98 | job->next_run = 0; |
| 99 | goto leave; |
| 100 | } |
| 101 | |
| 102 | if (md_will_renew_cert(md)) { |
| 103 | /* Renew the MDs credentials in a STAGING area. Might be invoked repeatedly |
| 104 | * without discarding previous/intermediate results. |
| 105 | * Only returns SUCCESS when the renewal is complete, e.g. STAGING has a |
| 106 | * complete set of new credentials. |
| 107 | */ |
| 108 | apr_time_t renew_at, now; |
| 109 | const char *ari_explain_url = NULL; |
| 110 | |
| 111 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, dctx->s, APLOGNO(10052) |
| 112 | "md(%s): state=%d, driving", job->mdomain, md->state); |
| 113 | |
| 114 | renew_at = md_reg_renew_at(dctx->mc->reg, md, ptemp); |
| 115 | now = apr_time_now(); |
| 116 | |
| 117 | if (md->stapling && dctx->mc->ocsp && |
| 118 | md_reg_has_revoked_certs(dctx->mc->reg, dctx->mc->ocsp, md, ptemp)) { |
| 119 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, dctx->s, APLOGNO(10500) |
| 120 | "md(%s): need to renew, OCSP reports revoked " |
| 121 | "certificate(s)", job->mdomain); |
| 122 | } |
| 123 | else if (!renew_at || renew_at <= now) { |
| 124 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, dctx->s, APLOGNO(10512) |
| 125 | "md(%s): need to renew now", job->mdomain); |
| 126 | } |
| 127 | else { |
| 128 | apr_time_t ari_renew_at = 0; |
| 129 | char ts[APR_RFC822_DATE_LEN]; |
no test coverage detected