| 782 | } |
| 783 | |
| 784 | apr_status_t md_acme_setup(md_acme_t *acme, md_result_t *result) |
| 785 | { |
| 786 | apr_status_t rv; |
| 787 | update_dir_ctx ctx; |
| 788 | |
| 789 | assert(acme->url); |
| 790 | acme->version = MD_ACME_VERSION_UNKNOWN; |
| 791 | |
| 792 | if (!acme->http && APR_SUCCESS != (rv = md_http_create(&acme->http, acme->p, |
| 793 | acme->user_agent, acme->proxy_url))) { |
| 794 | return rv; |
| 795 | } |
| 796 | /* TODO: maybe this should be configurable. Let's take some reasonable |
| 797 | * defaults for now that protect our client */ |
| 798 | md_http_set_response_limit(acme->http, 1024*1024); |
| 799 | md_http_set_timeout_default(acme->http, apr_time_from_sec(10 * 60)); |
| 800 | md_http_set_connect_timeout_default(acme->http, apr_time_from_sec(30)); |
| 801 | md_http_set_stalling_default(acme->http, 10, apr_time_from_sec(30)); |
| 802 | md_http_set_ca_file(acme->http, acme->ca_file); |
| 803 | |
| 804 | md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, 0, acme->p, "get directory from %s", acme->url); |
| 805 | |
| 806 | ctx.acme = acme; |
| 807 | ctx.result = result; |
| 808 | rv = md_http_GET_perform(acme->http, acme->url, NULL, update_directory, &ctx); |
| 809 | |
| 810 | if (APR_SUCCESS != rv && APR_SUCCESS == result->status) { |
| 811 | /* If the result reports no error, we never got a response from the server */ |
| 812 | md_result_printf(result, rv, |
| 813 | "Unsuccessful in contacting ACME server at <%s>. If this problem persists, " |
| 814 | "please check your network connectivity from your Apache server to the " |
| 815 | "ACME server. Also, older servers might have trouble verifying the certificates " |
| 816 | "of the ACME server. You can check if you are able to contact it manually via the " |
| 817 | "curl command. Sometimes, the ACME server might be down for maintenance, " |
| 818 | "so failing to contact it is not an immediate problem. Apache will " |
| 819 | "continue retrying this.", acme->url); |
| 820 | md_result_log(result, MD_LOG_WARNING); |
| 821 | } |
| 822 | return rv; |
| 823 | } |
| 824 | |
| 825 |
no test coverage detected