| 416 | } |
| 417 | |
| 418 | static apr_status_t cha_dns_01_setup(md_acme_authz_cha_t *cha, md_acme_authz_t *authz, |
| 419 | md_acme_t *acme, md_store_t *store, |
| 420 | md_pkeys_spec_t *key_specs, |
| 421 | apr_array_header_t *acme_tls_1_domains, const md_t *md, |
| 422 | apr_table_t *env, md_result_t *result, |
| 423 | const char **psetup_token, apr_pool_t *p) |
| 424 | { |
| 425 | const char *token; |
| 426 | const char * const *argv; |
| 427 | const char *cmdline, *dns01_cmd; |
| 428 | apr_status_t rv; |
| 429 | int exit_code, notify_server; |
| 430 | authz_req_ctx ctx; |
| 431 | md_data_t data; |
| 432 | const char *event; |
| 433 | |
| 434 | (void)store; |
| 435 | (void)key_specs; |
| 436 | (void)acme_tls_1_domains; |
| 437 | |
| 438 | dns01_cmd = md->dns01_cmd; |
| 439 | if (!dns01_cmd) |
| 440 | dns01_cmd = apr_table_get(env, MD_KEY_CMD_DNS01); |
| 441 | if (!dns01_cmd) { |
| 442 | rv = APR_ENOTIMPL; |
| 443 | md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, rv, p, "%s: dns-01 command not set", |
| 444 | authz->domain); |
| 445 | goto out; |
| 446 | } |
| 447 | |
| 448 | if (APR_SUCCESS != (rv = setup_key_authz(cha, authz, acme, p, ¬ify_server))) { |
| 449 | goto out; |
| 450 | } |
| 451 | |
| 452 | md_data_init_str(&data, cha->key_authz); |
| 453 | rv = md_crypt_sha256_digest64(&token, p, &data); |
| 454 | if (APR_SUCCESS != rv) { |
| 455 | md_log_perror(MD_LOG_MARK, MD_LOG_ERR, rv, p, "%s: create dns-01 token for %s", |
| 456 | md->name, authz->domain); |
| 457 | goto out; |
| 458 | } |
| 459 | |
| 460 | cmdline = apr_psprintf(p, "%s setup %s %s", dns01_cmd, authz->domain, token); |
| 461 | md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, 0, p, |
| 462 | "%s: dns-01 setup command: %s", authz->domain, cmdline); |
| 463 | |
| 464 | apr_tokenize_to_argv(cmdline, (char***)&argv, p); |
| 465 | if (APR_SUCCESS != (rv = md_util_exec(p, argv[0], argv, &exit_code))) { |
| 466 | md_log_perror(MD_LOG_MARK, MD_LOG_WARNING, rv, p, |
| 467 | "%s: dns-01 setup command failed to execute for %s", md->name, authz->domain); |
| 468 | goto out; |
| 469 | } |
| 470 | if (exit_code) { |
| 471 | rv = APR_EGENERAL; |
| 472 | md_log_perror(MD_LOG_MARK, MD_LOG_INFO, rv, p, |
| 473 | "%s: dns-01 setup command returns %d for %s", md->name, exit_code, authz->domain); |
| 474 | goto out; |
| 475 | } |
nothing calls this directly
no test coverage detected