Apache2
md_store.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_store_h
18 #define mod_md_md_store_h
19 
20 struct apr_array_header_t;
21 struct md_cert_t;
22 struct md_pkey_t;
23 struct md_pkey_spec_t;
24 
25 const char *md_store_group_name(unsigned int group);
26 
27 typedef struct md_store_t md_store_t;
28 
52 typedef enum {
53  MD_SV_TEXT, /* plain text, value is (char*) */
54  MD_SV_JSON, /* JSON serialization, value is (md_json_t*) */
55  MD_SV_CERT, /* PEM x509 certificate, value is (md_cert_t*) */
56  MD_SV_PKEY, /* PEM private key, value is (md_pkey_t*) */
57  MD_SV_CHAIN, /* list of PEM x509 certificates, value is
58  (apr_array_header_t*) of (md_cert*) */
60 
62 typedef enum {
63  MD_SG_NONE, /* top level of store, name MUST be NULL in calls */
64  MD_SG_ACCOUNTS, /* ACME accounts */
65  MD_SG_CHALLENGES, /* challenge response data for a domain */
66  MD_SG_DOMAINS, /* live certificates and settings for a domain */
67  MD_SG_STAGING, /* staged set of certificate and settings, maybe incomplete */
68  MD_SG_ARCHIVE, /* Archived live sets of a domain */
69  MD_SG_TMP, /* temporary domain storage */
70  MD_SG_OCSP, /* OCSP stapling related domain data */
71  MD_SG_COUNT, /* number of storage groups, used in setups */
73 
74 #define MD_FN_MD "md.json"
75 #define MD_FN_JOB "job.json"
76 #define MD_FN_HTTPD_JSON "httpd.json"
77 
78 /* The corresponding names for current cert & key files are constructed
79  * in md_store and md_crypt.
80  */
81 
82 /* These three legacy filenames are only used in md_store_fs to
83  * upgrade 1.0 directories. They should not be used for any other
84  * purpose.
85  */
86 #define MD_FN_PRIVKEY "privkey.pem"
87 #define MD_FN_PUBCERT "pubcert.pem"
88 #define MD_FN_CERT "cert.pem"
89 
95  const char *name, const char *aspect,
96  struct md_json_t **pdata, apr_pool_t *p);
102  const char *name, const char *aspect,
103  struct md_json_t *data, int create);
104 
112  const char *name, const char *aspect,
113  md_store_vtype_t vtype, void **pdata,
114  apr_pool_t *p);
120  const char *name, const char *aspect,
121  md_store_vtype_t vtype, void *data,
122  int create);
123 
129  const char *name, const char *aspect,
130  apr_pool_t *p, int force);
135  md_store_group_t group, const char *name);
136 
142  apr_time_t modified,
144  const char *name,
145  const char *aspect);
146 
152 typedef int md_store_inspect(void *baton, const char *name, const char *aspect,
153  md_store_vtype_t vtype, void *value, apr_pool_t *ptemp);
154 
159 apr_status_t md_store_iter(md_store_inspect *inspect, void *baton, md_store_t *store,
160  apr_pool_t *p, md_store_group_t group, const char *pattern,
161  const char *aspect, md_store_vtype_t vtype);
162 
169  const char *name, int archive);
170 
175  md_store_group_t group, const char *name, const char *to);
176 
181 apr_status_t md_store_get_fname(const char **pfname,
183  const char *name, const char *aspect,
184  apr_pool_t *p);
185 
190  const char *name, const char *aspect, apr_pool_t *p);
191 
197 apr_status_t md_store_iter_names(md_store_inspect *inspect, void *baton, md_store_t *store,
198  apr_pool_t *p, md_store_group_t group, const char *pattern);
199 
205  const char *name, const char *aspect, apr_pool_t *p);
206 
207 
208 
209 /**************************************************************************************************/
210 /* Storage handling utils */
211 
213  const char *name, md_t **pmd, apr_pool_t *p);
215  md_t *md, int create);
217  const char *name, int force);
218 
219 int md_is_newer(md_store_t *store, md_store_group_t group1, md_store_group_t group2,
220  const char *name, apr_pool_t *p);
221 
222 typedef int md_store_md_inspect(void *baton, md_store_t *store, md_t *md, apr_pool_t *ptemp);
223 
224 apr_status_t md_store_md_iter(md_store_md_inspect *inspect, void *baton, md_store_t *store,
225  apr_pool_t *p, md_store_group_t group, const char *pattern);
226 
227 
228 const char *md_pkey_filename(struct md_pkey_spec_t *spec, apr_pool_t *p);
229 const char *md_chain_filename(struct md_pkey_spec_t *spec, apr_pool_t *p);
230 
232  const char *name, struct md_pkey_spec_t *spec,
233  struct md_pkey_t **ppkey, apr_pool_t *p);
235  const char *name, struct md_pkey_spec_t *spec,
236  struct md_pkey_t *pkey, int create);
237 
239  struct md_pkey_spec_t *spec, struct apr_array_header_t **ppubcert,
240  apr_pool_t *p);
242  md_store_group_t group, const char *name,
243  struct md_pkey_spec_t *spec,
244  struct apr_array_header_t *pubcert, int create);
245 
246 /**************************************************************************************************/
247 /* X509 complete credentials */
248 
252  struct md_pkey_t *pkey;
254 };
255 
257  struct md_pkey_spec_t *spec, md_credentials_t **pcreds, apr_pool_t *p);
259  const char *name, md_credentials_t *creds, int create);
260 
261 /**************************************************************************************************/
262 /* implementation interface */
263 
265  const char *name, const char *aspect,
266  md_store_vtype_t vtype, void **pvalue,
267  apr_pool_t *p);
269  const char *name, const char *aspect,
270  md_store_vtype_t vtype, void *value,
271  int create);
273  const char *name, const char *aspect,
274  apr_pool_t *p, int force);
276  const char *name);
277 
278 typedef apr_status_t md_store_iter_cb(md_store_inspect *inspect, void *baton, md_store_t *store,
279  apr_pool_t *p, md_store_group_t group, const char *pattern,
280  const char *aspect, md_store_vtype_t vtype);
281 
282 typedef apr_status_t md_store_names_iter_cb(md_store_inspect *inspect, void *baton, md_store_t *store,
283  apr_pool_t *p, md_store_group_t group, const char *pattern);
284 
286  md_store_group_t to, const char *name, int archive);
287 
289  const char *from, const char *to);
290 
291 typedef apr_status_t md_store_get_fname_cb(const char **pfname,
293  const char *name, const char *aspect,
294  apr_pool_t *p);
295 
296 typedef int md_store_is_newer_cb(md_store_t *store,
297  md_store_group_t group1, md_store_group_t group2,
298  const char *name, const char *aspect, apr_pool_t *p);
299 
301  const char *name, const char *aspect, apr_pool_t *p);
302 
304  apr_time_t modified, md_store_group_t group,
305  const char *name, const char *aspect);
306 
307 struct md_store_t {
320 };
321 
322 
323 #endif /* mod_md_md_store_h */
apr_status_t md_pubcert_load(md_store_t *store, md_store_group_t group, const char *name, struct md_pkey_spec_t *spec, struct apr_array_header_t **ppubcert, apr_pool_t *p)
Definition: md_store.h:67
struct md_cert_t md_cert_t
Definition: md_crypt.h:122
apr_status_t md_store_load_json(md_store_t *store, md_store_group_t group, const char *name, const char *aspect, struct md_json_t **pdata, apr_pool_t *p)
Definition: md.h:76
Definition: md_store.h:307
struct md_json_t md_json_t
Definition: md_json.h:29
apr_status_t md_save(struct md_store_t *store, apr_pool_t *p, md_store_group_t group, md_t *md, int create)
apr_status_t md_store_move_cb(md_store_t *store, apr_pool_t *p, md_store_group_t from, md_store_group_t to, const char *name, int archive)
Definition: md_store.h:285
apr_status_t md_remove(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name, int force)
apr_status_t md_store_save(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name, const char *aspect, md_store_vtype_t vtype, void *data, int create)
Definition: apr_tables.h:62
apr_status_t md_pubcert_save(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name, struct md_pkey_spec_t *spec, struct apr_array_header_t *pubcert, int create)
md_store_group_t
Definition: md_store.h:62
apr_status_t md_store_iter_cb(md_store_inspect *inspect, void *baton, md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *pattern, const char *aspect, md_store_vtype_t vtype)
Definition: md_store.h:278
Definition: md_store.h:56
md_store_purge_cb * purge
Definition: md_store.h:315
apr_status_t md_store_save_json(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name, const char *aspect, struct md_json_t *data, int create)
md_store_remove_nms_cb * remove_nms
Definition: md_store.h:319
apr_time_t md_store_get_modified(md_store_t *store, md_store_group_t group, const char *name, const char *aspect, apr_pool_t *p)
apr_status_t md_store_rename_cb(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *from, const char *to)
Definition: md_store.h:288
Definition: md_store.h:65
apr_status_t md_store_purge(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name)
int md_store_md_inspect(void *baton, md_store_t *store, md_t *md, apr_pool_t *ptemp)
Definition: md_store.h:222
apr_status_t md_store_iter(md_store_inspect *inspect, void *baton, md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *pattern, const char *aspect, md_store_vtype_t vtype)
apr_status_t md_store_get_fname_cb(const char **pfname, md_store_t *store, md_store_group_t group, const char *name, const char *aspect, apr_pool_t *p)
Definition: md_store.h:291
int md_is_newer(md_store_t *store, md_store_group_t group1, md_store_group_t group2, const char *name, apr_pool_t *p)
Definition: md_store.h:66
const char * md_chain_filename(struct md_pkey_spec_t *spec, apr_pool_t *p)
apr_status_t md_store_md_iter(md_store_md_inspect *inspect, void *baton, md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *pattern)
md_store_vtype_t
Definition: md_store.h:52
apr_status_t md_pkey_load(md_store_t *store, md_store_group_t group, const char *name, struct md_pkey_spec_t *spec, struct md_pkey_t **ppkey, apr_pool_t *p)
apr_status_t md_store_remove(md_store_t *store, md_store_group_t group, const char *name, const char *aspect, apr_pool_t *p, int force)
apr_status_t md_store_remove_nms_cb(md_store_t *store, apr_pool_t *p, apr_time_t modified, md_store_group_t group, const char *name, const char *aspect)
Definition: md_store.h:303
md_store_is_newer_cb * is_newer
Definition: md_store.h:317
const char * md_pkey_filename(struct md_pkey_spec_t *spec, apr_pool_t *p)
apr_status_t md_creds_save(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name, md_credentials_t *creds, int create)
apr_int64_t apr_time_t
Definition: apr_time.h:45
Definition: md_store.h:71
int md_store_inspect(void *baton, const char *name, const char *aspect, md_store_vtype_t vtype, void *value, apr_pool_t *ptemp)
Definition: md_store.h:152
const char * md_store_group_name(unsigned int group)
apr_status_t md_store_load_cb(md_store_t *store, md_store_group_t group, const char *name, const char *aspect, md_store_vtype_t vtype, void **pvalue, apr_pool_t *p)
Definition: md_store.h:264
apr_status_t md_store_names_iter_cb(md_store_inspect *inspect, void *baton, md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *pattern)
Definition: md_store.h:282
Definition: md_store.h:57
apr_status_t md_store_move(md_store_t *store, apr_pool_t *p, md_store_group_t from, md_store_group_t to, const char *name, int archive)
const char const dav_liveprop_group * group
Definition: mod_dav.h:1048
apr_status_t md_store_iter_names(md_store_inspect *inspect, void *baton, md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *pattern)
apr_status_t md_store_load(md_store_t *store, md_store_group_t group, const char *name, const char *aspect, md_store_vtype_t vtype, void **pdata, apr_pool_t *p)
Definition: md_store.h:68
md_store_load_cb * load
Definition: md_store.h:309
Definition: md_store.h:54
md_store_get_fname_cb * get_fname
Definition: md_store.h:316
md_store_names_iter_cb * iterate_names
Definition: md_store.h:314
apr_status_t md_load(md_store_t *store, md_store_group_t group, const char *name, md_t **pmd, apr_pool_t *p)
apr_status_t md_store_get_fname(const char **pfname, md_store_t *store, md_store_group_t group, const char *name, const char *aspect, apr_pool_t *p)
apr_pool_t * p
md_store_get_modified_cb * get_modified
Definition: md_store.h:318
md_store_save_cb * save
Definition: md_store.h:308
apr_status_t md_creds_load(md_store_t *store, md_store_group_t group, const char *name, struct md_pkey_spec_t *spec, md_credentials_t **pcreds, apr_pool_t *p)
Definition: md_store.h:63
int md_store_is_newer_cb(md_store_t *store, md_store_group_t group1, md_store_group_t group2, const char *name, const char *aspect, apr_pool_t *p)
Definition: md_store.h:296
apr_status_t md_store_remove_not_modified_since(md_store_t *store, apr_pool_t *p, apr_time_t modified, md_store_group_t group, const char *name, const char *aspect)
md_store_iter_cb * iterate
Definition: md_store.h:313
md_store_move_cb * move
Definition: md_store.h:311
int md_store_is_newer(md_store_t *store, md_store_group_t group1, md_store_group_t group2, const char *name, const char *aspect, apr_pool_t *p)
apr_time_t md_store_get_modified_cb(md_store_t *store, md_store_group_t group, const char *name, const char *aspect, apr_pool_t *p)
Definition: md_store.h:300
apr_status_t md_store_save_cb(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name, const char *aspect, md_store_vtype_t vtype, void *value, int create)
Definition: md_store.h:268
Definition: md_store.h:55
const char * name
Definition: mod_dav.h:805
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
md_store_rename_cb * rename
Definition: md_store.h:312
apr_status_t md_pkey_save(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name, struct md_pkey_spec_t *spec, struct md_pkey_t *pkey, int create)
int apr_status_t
Definition: apr_errno.h:44
struct apr_array_header_t * chain
Definition: md_store.h:253
struct md_pkey_t * pkey
Definition: md_store.h:252
Definition: md_store.h:53
apr_status_t md_store_purge_cb(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name)
Definition: md_store.h:275
apr_status_t md_store_rename(md_store_t *store, apr_pool_t *p, md_store_group_t group, const char *name, const char *to)
struct md_pkey_t md_pkey_t
Definition: md_crypt.h:49
Definition: md_store.h:70
Definition: md_store.h:250
struct md_pkey_spec_t * spec
Definition: md_store.h:251
Definition: md_store.h:64
Definition: md_crypt.h:65
Definition: md_store.h:69
apr_status_t md_store_remove_cb(md_store_t *store, md_store_group_t group, const char *name, const char *aspect, apr_pool_t *p, int force)
Definition: md_store.h:272