Apache HTTPD
md_acme.h
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef mod_md_md_acme_h
18#define mod_md_md_acme_h
19
23struct apr_hash_t;
24struct md_http_t;
25struct md_json_t;
26struct md_pkey_t;
27struct md_t;
28struct md_acme_acct_t;
29struct md_acmev2_acct_t;
30struct md_store_t;
31struct md_result_t;
32
33#define MD_PROTO_ACME "ACME"
34
35#define MD_AUTHZ_CHA_HTTP_01 "http-01"
36#define MD_AUTHZ_CHA_SNI_01 "tls-sni-01"
37
38#define MD_ACME_VERSION_UNKNOWN 0x0
39#define MD_ACME_VERSION_1 0x010000
40#define MD_ACME_VERSION_2 0x020000
41
42#define MD_ACME_VERSION_MAJOR(i) (((i)&0xFF0000) >> 16)
43
44typedef enum {
45 MD_ACME_S_UNKNOWN, /* MD has not been analysed yet */
46 MD_ACME_S_REGISTERED, /* MD is registered at CA, but not more */
47 MD_ACME_S_TOS_ACCEPTED, /* Terms of Service were accepted by account holder */
48 MD_ACME_S_CHALLENGED, /* MD challenge information for all domains is known */
49 MD_ACME_S_VALIDATED, /* MD domains have been validated */
50 MD_ACME_S_CERTIFIED, /* MD has valid certificate */
51 MD_ACME_S_DENIED, /* MD domains (at least one) have been denied by CA */
53
54typedef struct md_acme_t md_acme_t;
55
61 const struct md_http_response_t *res, void *baton);
62
68
74 const apr_table_t *headers,
75 struct md_json_t *jbody, void *baton);
76
81 const struct md_result_t *result, void *baton);
82
83
86
92 void *baton);
93
94struct md_acme_t {
95 const char *url; /* directory url of the ACME service */
96 const char *sname; /* short name for the service, not necessarily unique */
98 const char *user_agent;
99 const char *proxy_url;
100 const char *ca_file;
101
102 const char *acct_id; /* local storage id account was loaded from or NULL */
103 struct md_acme_acct_t *acct; /* account at ACME server to use for requests */
104 struct md_pkey_t *acct_key; /* private RSA key belonging to account */
105
106 int version; /* as detected from the server */
107 union {
108 struct { /* obsolete */
109 const char *new_authz;
110 const char *new_cert;
111 const char *new_reg;
112 const char *revoke_cert;
113
114 } v1;
115 struct {
116 const char *new_account;
117 const char *new_order;
118 const char *key_change;
119 const char *revoke_cert;
120 const char *new_nonce;
121 } v2;
123 const char *ca_agreement;
124 const char *acct_name;
126
130
132
133 const char *nonce;
135 struct md_result_t *last; /* result of last request */
136};
137
142
154 const char *proxy_url, const char *ca_file);
155
162
164
165/**************************************************************************************************/
166/* account handling */
167
171void md_acme_clear_acct(md_acme_t *acme);
172
174 md_acme_req_init_cb *on_init,
175 md_acme_req_json_cb *on_json,
176 md_acme_req_res_cb *on_res,
177 md_acme_req_err_cb *on_err,
178 void *baton);
179
184const char *md_acme_acct_id_get(md_acme_t *acme);
185const char *md_acme_acct_url_get(md_acme_t *acme);
186
196 apr_pool_t *p, const char *acct_id);
197
208 apr_pool_t *p, const char *acct_id,
209 const md_t *md);
210
215const char *md_acme_acct_id_get(md_acme_t *acme);
216
220apr_status_t md_acme_agree(md_acme_t *acme, apr_pool_t *p, const char *tos);
221
235 const char *agreement, const char **prequired);
236
238
243
244/**************************************************************************************************/
245/* request handling */
246
248 md_acme_t *acme; /* the ACME server to talk to */
249 apr_pool_t *p; /* pool for the request duration */
250
251 const char *url; /* url to POST the request to */
252 const char *method; /* HTTP method to use */
253 struct md_json_t *prot_fields; /* JWS protected fields */
254 struct md_json_t *req_json; /* JSON to be POSTed in request body */
255
256 apr_table_t *resp_hdrs; /* HTTP response headers */
257 struct md_json_t *resp_json; /* JSON response body received */
258
259 apr_status_t rv; /* status of request */
260
261 md_acme_req_init_cb *on_init; /* callback to initialize the request before submit */
262 md_acme_req_json_cb *on_json; /* callback on successful JSON response */
263 md_acme_req_res_cb *on_res; /* callback on generic HTTP response */
264 md_acme_req_err_cb *on_err; /* callback on encountered error */
265 int max_retries; /* how often this might be retried */
266 void *baton; /* userdata for callbacks */
267 struct md_result_t *result; /* result of this request */
268};
269
271
272apr_status_t md_acme_GET(md_acme_t *acme, const char *url,
273 md_acme_req_init_cb *on_init,
274 md_acme_req_json_cb *on_json,
275 md_acme_req_res_cb *on_res,
276 md_acme_req_err_cb *on_err,
277 void *baton);
292apr_status_t md_acme_POST(md_acme_t *acme, const char *url,
293 md_acme_req_init_cb *on_init,
294 md_acme_req_json_cb *on_json,
295 md_acme_req_res_cb *on_res,
296 md_acme_req_err_cb *on_err,
297 void *baton);
298
303 const char *url, apr_pool_t *p);
304
305
307
309
316
317#endif /* md_acme_h */
ap_vhost_iterate_conn_cb void * baton
Definition http_vhost.h:87
apr_pool_t apr_dbd_t apr_dbd_results_t ** res
Definition apr_dbd.h:287
const char * url
Definition apr_escape.h:120
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
int apr_status_t
Definition apr_errno.h:44
apr_array_header_t ** result
const char * md_acme_acct_url_get(md_acme_t *acme)
Definition md_acme.c:538
apr_status_t md_acme_get_json(struct md_json_t **pjson, md_acme_t *acme, const char *url, apr_pool_t *p)
Definition md_acme.c:509
apr_status_t md_acme_agree(md_acme_t *acme, apr_pool_t *p, const char *tos)
apr_status_t md_acme_req_json_cb(md_acme_t *acme, apr_pool_t *p, const apr_table_t *headers, struct md_json_t *jbody, void *baton)
Definition md_acme.h:73
apr_status_t md_acme_post_fn(md_acme_t *acme, md_acme_req_init_cb *on_init, md_acme_req_json_cb *on_json, md_acme_req_res_cb *on_res, md_acme_req_err_cb *on_err, void *baton)
Definition md_acme.h:87
void md_acme_clear_acct(md_acme_t *acme)
Definition md_acme.c:526
apr_status_t md_acme_use_acct_for_md(md_acme_t *acme, struct md_store_t *store, apr_pool_t *p, const char *acct_id, const md_t *md)
Definition md_acme.c:567
apr_status_t md_acme_req_init_cb(md_acme_req_t *req, void *baton)
Definition md_acme.h:67
apr_status_t md_acme_req_init_fn(md_acme_req_t *req, struct md_json_t *jpayload)
Definition md_acme.h:85
md_acme_state_t
Definition md_acme.h:44
@ MD_ACME_S_VALIDATED
Definition md_acme.h:49
@ MD_ACME_S_CERTIFIED
Definition md_acme.h:50
@ MD_ACME_S_UNKNOWN
Definition md_acme.h:45
@ MD_ACME_S_REGISTERED
Definition md_acme.h:46
@ MD_ACME_S_CHALLENGED
Definition md_acme.h:48
@ MD_ACME_S_DENIED
Definition md_acme.h:51
@ MD_ACME_S_TOS_ACCEPTED
Definition md_acme.h:47
const char * md_acme_acct_id_get(md_acme_t *acme)
Definition md_acme.c:533
apr_status_t md_acme_req_res_cb(md_acme_t *acme, const struct md_http_response_t *res, void *baton)
Definition md_acme.h:60
int md_acme_problem_is_input_related(const char *problem)
Definition md_acme.c:91
apr_status_t md_acme_req_err_cb(md_acme_req_t *req, const struct md_result_t *result, void *baton)
Definition md_acme.h:80
apr_status_t md_acme_acct_deactivate(md_acme_t *acme, apr_pool_t *p)
apr_status_t md_acme_use_acct(md_acme_t *acme, struct md_store_t *store, apr_pool_t *p, const char *acct_id)
Definition md_acme.c:543
apr_status_t md_acme_protos_add(struct apr_hash_t *protos, apr_pool_t *p)
apr_status_t md_acme_POST_new_account(md_acme_t *acme, md_acme_req_init_cb *on_init, md_acme_req_json_cb *on_json, md_acme_req_res_cb *on_res, md_acme_req_err_cb *on_err, void *baton)
Definition md_acme.c:607
apr_status_t md_acme_req_body_init(md_acme_req_t *req, struct md_json_t *payload)
Definition md_acme.c:250
apr_status_t md_acme_GET(md_acme_t *acme, const char *url, md_acme_req_init_cb *on_init, md_acme_req_json_cb *on_json, md_acme_req_res_cb *on_res, md_acme_req_err_cb *on_err, void *baton)
Definition md_acme.c:455
apr_status_t md_acme_check_agreement(md_acme_t *acme, apr_pool_t *p, const char *agreement, const char **prequired)
apr_status_t md_acme_init(apr_pool_t *pool, const char *base_version, int init_ssl)
Definition md_acme.c:163
apr_status_t md_acme_setup(md_acme_t *acme, struct md_result_t *result)
Definition md_acme.c:756
apr_status_t md_acme_POST(md_acme_t *acme, const char *url, md_acme_req_init_cb *on_init, md_acme_req_json_cb *on_json, md_acme_req_res_cb *on_res, md_acme_req_err_cb *on_err, void *baton)
Definition md_acme.c:432
apr_status_t md_acme_new_nonce_fn(md_acme_t *acme)
Definition md_acme.h:84
apr_status_t md_acme_save_acct(md_acme_t *acme, apr_pool_t *p, struct md_store_t *store)
Definition md_acme.c:592
apr_status_t md_acme_create(md_acme_t **pacme, apr_pool_t *p, const char *url, const char *proxy_url, const char *ca_file)
Definition md_acme.c:620
void md_acme_report_result(md_acme_t *acme, apr_status_t rv, struct md_result_t *result)
Definition md_acme.c:478
apr_pool_t * p
Definition md_event.c:32
static void init_ssl(void)
Definition mod_md.c:112
apr_pool_t * p
Definition md_acme.h:249
struct md_result_t * result
Definition md_acme.h:267
struct md_json_t * req_json
Definition md_acme.h:254
void * baton
Definition md_acme.h:266
md_acme_req_err_cb * on_err
Definition md_acme.h:264
md_acme_req_res_cb * on_res
Definition md_acme.h:263
md_acme_req_json_cb * on_json
Definition md_acme.h:262
const char * method
Definition md_acme.h:252
struct md_json_t * resp_json
Definition md_acme.h:257
int max_retries
Definition md_acme.h:265
struct md_json_t * prot_fields
Definition md_acme.h:253
const char * url
Definition md_acme.h:251
md_acme_t * acme
Definition md_acme.h:248
apr_table_t * resp_hdrs
Definition md_acme.h:256
md_acme_req_init_cb * on_init
Definition md_acme.h:261
apr_status_t rv
Definition md_acme.h:259
struct md_result_t * last
Definition md_acme.h:135
const char * revoke_cert
Definition md_acme.h:112
const char * new_account
Definition md_acme.h:116
int version
Definition md_acme.h:106
int max_retries
Definition md_acme.h:134
md_acme_post_fn * post_new_account_fn
Definition md_acme.h:129
const char * new_reg
Definition md_acme.h:111
apr_pool_t * p
Definition md_acme.h:97
const char * proxy_url
Definition md_acme.h:99
const char * ca_agreement
Definition md_acme.h:123
const char * new_authz
Definition md_acme.h:109
union md_acme_t::@21 api
const char * user_agent
Definition md_acme.h:98
int eab_required
Definition md_acme.h:125
struct md_http_t * http
Definition md_acme.h:131
const char * new_nonce
Definition md_acme.h:120
const char * new_cert
Definition md_acme.h:110
md_acme_req_init_fn * req_init_fn
Definition md_acme.h:128
struct md_acme_acct_t * acct
Definition md_acme.h:103
const char * nonce
Definition md_acme.h:133
const char * key_change
Definition md_acme.h:118
const char * new_order
Definition md_acme.h:117
const char * url
Definition md_acme.h:95
struct md_pkey_t * acct_key
Definition md_acme.h:104
const char * sname
Definition md_acme.h:96
const char * acct_name
Definition md_acme.h:124
const char * ca_file
Definition md_acme.h:100
md_acme_new_nonce_fn * new_nonce_fn
Definition md_acme.h:127
const char * acct_id
Definition md_acme.h:102
const char * problem
Definition md_result.h:33
Definition md.h:76