/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
(void)env;
(void)md; if (md_array_str_index(acme_tls_1_domains, authz->domain, 0, 0) < 0) {
rv = APR_ENOTIMPL; if (acme_tls_1_domains->nelts) {
md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, 0, p, "%s: protocol 'acme-tls/1' seems not enabled for this domain, " "but is enabled for other associated domains. " "Continuing with fingers crossed.", authz->domain);
} else {
md_log_perror(MD_LOG_MARK, MD_LOG_INFO, 0, p, "%s: protocol 'acme-tls/1' seems not enabled for this or " "any other associated domain. Not attempting challenge " "type tls-alpn-01.", authz->domain); goto out;
}
} if (APR_SUCCESS != (rv = setup_key_authz(cha, authz, acme, p, ¬ify_server))) { goto out;
}
/* Create a "tls-alpn-01" certificate for the domain we want to authenticate. * The server will need to answer a TLS connection with SNI == authz->domain * and ALPN protocol "acme-tls/1" with this certificate.
*/
md_data_init_str(&data, cha->key_authz);
rv = md_crypt_sha256_digest_hex(&token, p, &data); if (APR_SUCCESS != rv) {
md_log_perror(MD_LOG_MARK, MD_LOG_ERR, rv, p, "%s: create tls-alpn-01 validation token",
authz->domain); goto out;
}
acme_id = apr_psprintf(p, "critical,DER:04:20:%s", token);
/* Each configured key type must be generated to ensure: * that any fallback certs already given to mod_ssl are replaced. * We expect that the validation client (at the CA) can deal with at * least one of them.
*/
for (i = 0; i < md_pkeys_spec_count(key_specs); ++i) { char *kfn, *cfn;
md_cert_t *cha_cert;
md_pkey_t *cha_key;
md_pkey_spec_t *key_spec;
/* Look in the order challenge types are defined: * - if they are offered by the CA, try to set it up * - if setup was successful, we are done and the CA will evaluate us * - if setup failed, continue to look for another supported challenge type * - if there is no overlap in types, tell the user that she has to configure * either more types (dns, tls-alpn-01), make ports available or refrain * from using wildcard domains when dns is not available. etc. * - if there was an overlap, but no setup was successful, report that. We * will retry this, maybe the failure is temporary (e.g. command to setup DNS
*/
md_result_printf(result, 0, "%s: selecting suitable authorization challenge " "type, this domain supports %s",
authz->domain, apr_array_pstrcat(p, challenges, ' '));
rv = APR_ENOTIMPL;
*psetup_token = NULL; for (i = 0; i < challenges->nelts; ++i) {
fctx.type = APR_ARRAY_IDX(challenges, i, constchar *);
fctx.accepted = NULL;
md_json_itera(find_type, &fctx, authz->resource, MD_KEY_CHALLENGES, NULL);
md_log_perror(MD_LOG_MARK, MD_LOG_TRACE1, 0, p, "%s: challenge type '%s' for %s: %s",
authz->domain, fctx.type, md->name,
fctx.accepted? "maybe acceptable" : "not applicable");
if (fctx.accepted) { for (j = 0; j < (int)CHA_TYPES_LEN; ++j) { if (!apr_strnatcasecmp(CHA_TYPES[j].name, fctx.accepted->type)) {
md_result_activity_printf(result, "Setting up challenge '%s' for domain %s",
fctx.accepted->type, authz->domain);
rv = CHA_TYPES[j].setup(fctx.accepted, authz, acme, store, key_specs,
acme_tls_1_domains, md, env, result,
psetup_token, p); if (APR_SUCCESS == rv) {
md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, rv, p, "%s: set up challenge '%s' for %s",
authz->domain, fctx.accepted->type, md->name); goto out;
}
md_result_printf(result, rv, "error setting up challenge '%s' for %s, " "for domain %s, looking for other option",
fctx.accepted->type, authz->domain, md->name);
md_result_log(result, MD_LOG_INFO);
}
}
}
}
out: if (!fctx.accepted || APR_ENOTIMPL == rv) {
rv = APR_EINVAL;
fctx.offered = apr_array_make(p, 5, sizeof(constchar*));
md_json_itera(collect_offered, &fctx, authz->resource, MD_KEY_CHALLENGES, NULL);
md_result_printf(result, rv, "None of offered challenge types for domain %s are supported. " "The server offered '%s' and available are: '%s'.",
authz->domain,
apr_array_pstrcat(p, fctx.offered, ' '),
apr_array_pstrcat(p, challenges, ' '));
result->problem = "challenge-mismatch";
md_result_log(result, MD_LOG_ERR);
} elseif (APR_SUCCESS != rv) {
fctx.offered = apr_array_make(p, 5, sizeof(constchar*));
md_json_itera(collect_offered, &fctx, authz->resource, MD_KEY_CHALLENGES, NULL);
md_result_printf(result, rv, "None of the offered challenge types %s offered " "for domain %s could be setup successfully. Please check the " "log for errors.", authz->domain,
apr_array_pstrcat(p, fctx.offered, ' '));
result->problem = "challenge-setup-failure";
md_result_log(result, MD_LOG_ERR);
} return rv;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.