| 534 | } |
| 535 | |
| 536 | static apr_status_t acme_driver_init(md_proto_driver_t *d, md_result_t *result) |
| 537 | { |
| 538 | md_acme_driver_t *ad; |
| 539 | int dis_http, dis_https, dis_alpn_acme, dis_dns; |
| 540 | const char *challenge; |
| 541 | |
| 542 | acme_driver_preload_init(d, result); |
| 543 | md_result_set(result, APR_SUCCESS, NULL); |
| 544 | if (APR_SUCCESS != result->status) goto leave; |
| 545 | |
| 546 | ad = d->baton; |
| 547 | |
| 548 | /* We can only support challenges if the server is reachable from the outside |
| 549 | * via port 80 and/or 443. These ports might be mapped for httpd to something |
| 550 | * else, but a mapping needs to exist. */ |
| 551 | challenge = apr_table_get(d->env, MD_KEY_CHALLENGE); |
| 552 | if (challenge) { |
| 553 | APR_ARRAY_PUSH(ad->ca_challenges, const char*) = apr_pstrdup(d->p, challenge); |
| 554 | } |
| 555 | else if (d->md->ca_challenges && d->md->ca_challenges->nelts > 0) { |
| 556 | /* pre-configured set for this managed domain */ |
| 557 | apr_array_cat(ad->ca_challenges, d->md->ca_challenges); |
| 558 | } |
| 559 | else { |
| 560 | /* free to chose. Add all we support and see what we get offered */ |
| 561 | APR_ARRAY_PUSH(ad->ca_challenges, const char*) = MD_AUTHZ_TYPE_TLSALPN01; |
| 562 | APR_ARRAY_PUSH(ad->ca_challenges, const char*) = MD_AUTHZ_TYPE_HTTP01; |
| 563 | APR_ARRAY_PUSH(ad->ca_challenges, const char*) = MD_AUTHZ_TYPE_DNS01; |
| 564 | |
| 565 | if (!d->can_http && !d->can_https |
| 566 | && md_array_str_index(ad->ca_challenges, MD_AUTHZ_TYPE_DNS01, 0, 0) < 0) { |
| 567 | md_result_printf(result, APR_EGENERAL, |
| 568 | "the server seems neither reachable via http (port 80) nor https (port 443). " |
| 569 | "Please look at the MDPortMap configuration directive on how to correct this. " |
| 570 | "The ACME protocol needs at least one of those so the CA can talk to the server " |
| 571 | "and verify a domain ownership. Alternatively, you may configure support " |
| 572 | "for the %s challenge directive.", MD_AUTHZ_TYPE_DNS01); |
| 573 | goto leave; |
| 574 | } |
| 575 | |
| 576 | dis_http = dis_https = dis_alpn_acme = dis_dns = 0; |
| 577 | if (!d->can_http && md_array_str_index(ad->ca_challenges, MD_AUTHZ_TYPE_HTTP01, 0, 1) >= 0) { |
| 578 | ad->ca_challenges = md_array_str_remove(d->p, ad->ca_challenges, MD_AUTHZ_TYPE_HTTP01, 0); |
| 579 | dis_http = 1; |
| 580 | } |
| 581 | if (!d->can_https && md_array_str_index(ad->ca_challenges, MD_AUTHZ_TYPE_TLSALPN01, 0, 1) >= 0) { |
| 582 | ad->ca_challenges = md_array_str_remove(d->p, ad->ca_challenges, MD_AUTHZ_TYPE_TLSALPN01, 0); |
| 583 | dis_https = 1; |
| 584 | } |
| 585 | if (apr_is_empty_array(d->md->acme_tls_1_domains) |
| 586 | && md_array_str_index(ad->ca_challenges, MD_AUTHZ_TYPE_TLSALPN01, 0, 1) >= 0) { |
| 587 | ad->ca_challenges = md_array_str_remove(d->p, ad->ca_challenges, MD_AUTHZ_TYPE_TLSALPN01, 0); |
| 588 | dis_alpn_acme = 1; |
| 589 | } |
| 590 | if (!apr_table_get(d->env, MD_KEY_CMD_DNS01) |
| 591 | && NULL == d->md->dns01_cmd |
| 592 | && md_array_str_index(ad->ca_challenges, MD_AUTHZ_TYPE_DNS01, 0, 1) >= 0) { |
| 593 | ad->ca_challenges = md_array_str_remove(d->p, ad->ca_challenges, MD_AUTHZ_TYPE_DNS01, 0); |
nothing calls this directly
no test coverage detected