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

Function md_reg_sync_finish

modules/md/md_reg.c:950–1024  ·  view source on GitHub ↗

* Finish syncing an MD with the store. * 1. if there are changed properties (or if the MD is new), save it. * 2. read any existing certificate and init the state of the memory MD */

Source from the content-addressed store, hash-verified

948 * 2. read any existing certificate and init the state of the memory MD
949 */
950apr_status_t md_reg_sync_finish(md_reg_t *reg, md_t *md, apr_pool_t *p, apr_pool_t *ptemp)
951{
952 md_t *old;
953 apr_status_t rv;
954 int changed = 1;
955 md_proto_t *proto;
956
957 if (!md->ca_proto) {
958 md->ca_proto = MD_PROTO_ACME;
959 }
960 proto = apr_hash_get(reg->protos, md->ca_proto, (apr_ssize_t)strlen(md->ca_proto));
961 if (!proto) {
962 rv = APR_ENOTIMPL;
963 md_log_perror(MD_LOG_MARK, MD_LOG_ERR, rv, ptemp,
964 "[%s] uses unknown CA protocol '%s'",
965 md->name, md->ca_proto);
966 goto leave;
967 }
968 rv = proto->complete_md(md, p);
969 if (APR_SUCCESS != rv) goto leave;
970
971 rv = state_init(reg, p, md);
972 if (APR_SUCCESS != rv) goto leave;
973
974 md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, rv, ptemp, "loading md %s", md->name);
975 if (APR_SUCCESS == md_load(reg->store, MD_SG_DOMAINS, md->name, &old, ptemp)) {
976 md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, rv, ptemp, "loaded md %s", md->name);
977 /* Some parts are kept from old, lacking new values */
978 if ((!md->contacts || apr_is_empty_array(md->contacts)) && old->contacts) {
979 md->contacts = md_array_str_clone(p, old->contacts);
980 }
981 if (md->ca_challenges && old->ca_challenges) {
982 if (!md_array_str_eq(md->ca_challenges, old->ca_challenges, 0)) {
983 md->ca_challenges = md_array_str_compact(p, md->ca_challenges, 0);
984 }
985 }
986 if (!md->ca_effective && old->ca_effective) {
987 md->ca_effective = apr_pstrdup(p, old->ca_effective);
988 }
989 if (!md->ca_account && old->ca_account) {
990 md->ca_account = apr_pstrdup(p, old->ca_account);
991 }
992
993 /* if everything remains the same, spare the write back */
994 if (!MD_VAL_UPDATE(md, old, state)
995 && md_array_str_eq(md->ca_urls, old->ca_urls, 0)
996 && !MD_SVAL_UPDATE(md, old, ca_proto)
997 && !MD_SVAL_UPDATE(md, old, ca_agreement)
998 && !MD_VAL_UPDATE(md, old, transitive)
999 && md_equal_domains(md, old, 1)
1000 && !MD_VAL_UPDATE(md, old, renew_mode)
1001 && md_timeslice_eq(md->renew_window, old->renew_window)
1002 && md_timeslice_eq(md->warn_window, old->warn_window)
1003 && md_pkeys_spec_eq(md->pks, old->pks)
1004 && !MD_VAL_UPDATE(md, old, require_https)
1005 && !MD_VAL_UPDATE(md, old, must_staple)
1006 && md_array_str_eq(md->acme_tls_1_domains, old->acme_tls_1_domains, 0)
1007 && !MD_VAL_UPDATE(md, old, stapling)

Callers 1

md_post_config_after_sslFunction · 0.85

Calls 10

md_log_perrorFunction · 0.85
state_initFunction · 0.85
md_loadFunction · 0.85
md_array_str_cloneFunction · 0.85
md_array_str_eqFunction · 0.85
md_array_str_compactFunction · 0.85
md_equal_domainsFunction · 0.85
md_timeslice_eqFunction · 0.85
md_pkeys_spec_eqFunction · 0.85
md_saveFunction · 0.85

Tested by

no test coverage detected