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

Function acme_preload

modules/md/md_acme_drive.c:941–1075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

939/* ACME preload */
940
941static apr_status_t acme_preload(md_proto_driver_t *d, md_store_group_t load_group,
942 const char *name, md_result_t *result)
943{
944 apr_status_t rv;
945 md_pkey_t *acct_key;
946 md_t *md;
947 md_pkey_spec_t *pkspec;
948 md_credentials_t *creds;
949 apr_array_header_t *all_creds;
950 struct md_acme_acct_t *acct;
951 const char *id;
952 int i;
953
954 md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, 0, d->p, "%s: preload start", name);
955 /* Load data from MD_SG_STAGING and save it into "load_group".
956 * This serves several purposes:
957 * 1. It's a format check on the input data.
958 * 2. We write back what we read, creating data with our own access permissions
959 * 3. We ignore any other accumulated data in STAGING
960 * 4. Once "load_group" is complete an ok, we can swap/archive groups with a rename
961 * 5. Reading/Writing the data will apply/remove any group specific data encryption.
962 */
963 if (APR_SUCCESS != (rv = md_load(d->store, MD_SG_STAGING, name, &md, d->p))) {
964 md_result_set(result, rv, "loading staged md.json");
965 goto leave;
966 }
967 if (!md->ca_effective) {
968 rv = APR_ENOENT;
969 md_result_set(result, rv, "effective CA url not set");
970 goto leave;
971 }
972
973 all_creds = apr_array_make(d->p, 5, sizeof(md_credentials_t*));
974 for (i = 0; i < md_pkeys_spec_count(md->pks); ++i) {
975 pkspec = md_pkeys_spec_get(md->pks, i);
976 if (APR_SUCCESS != (rv = md_creds_load(d->store, MD_SG_STAGING, name, pkspec, &creds, d->p))) {
977 md_result_printf(result, rv, "loading staged credentials #%d", i);
978 goto leave;
979 }
980 if (!creds->chain) {
981 rv = APR_ENOENT;
982 md_result_printf(result, rv, "no certificate in staged credentials #%d", i);
983 goto leave;
984 }
985 if (APR_SUCCESS != (rv = md_check_cert_and_pkey(creds->chain, creds->pkey))) {
986 md_result_printf(result, rv, "certificate and private key do not match in staged credentials #%d", i);
987 goto leave;
988 }
989 APR_ARRAY_PUSH(all_creds, md_credentials_t*) = creds;
990 }
991
992 /* See if staging holds a new or modified account data */
993 rv = md_acme_acct_load(&acct, &acct_key, d->store, MD_SG_STAGING, name, d->p);
994 if (APR_STATUS_IS_ENOENT(rv)) {
995 acct = NULL;
996 acct_key = NULL;
997 rv = APR_SUCCESS;
998 }

Callers 1

acme_driver_preloadFunction · 0.85

Calls 15

md_log_perrorFunction · 0.85
md_loadFunction · 0.85
md_result_setFunction · 0.85
md_pkeys_spec_countFunction · 0.85
md_pkeys_spec_getFunction · 0.85
md_creds_loadFunction · 0.85
md_result_printfFunction · 0.85
md_check_cert_and_pkeyFunction · 0.85
md_acme_acct_loadFunction · 0.85
md_result_activity_setnFunction · 0.85
md_acme_order_purgeFunction · 0.85
md_store_purgeFunction · 0.85

Tested by

no test coverage detected