Apache HTTPD
md.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_h
18#define mod_md_md_h
19
20#include <apr_time.h>
21
22#include "md_time.h"
23#include "md_version.h"
24
26struct apr_hash_t;
27struct md_json_t;
28struct md_cert_t;
29struct md_job_t;
30struct md_pkey_t;
31struct md_result_t;
32struct md_store_t;
33struct md_srv_conf_t;
34struct md_pkey_spec_t;
35
36#define MD_PKEY_RSA_BITS_MIN 2048
37#define MD_PKEY_RSA_BITS_DEF 2048
38
39/* Minimum age for the HSTS header (RFC 6797), considered appropriate by Mozilla Security */
40#define MD_HSTS_HEADER "Strict-Transport-Security"
41#define MD_HSTS_MAX_AGE_DEFAULT 15768000
42
43#define PROTO_ACME_TLS_1 "acme-tls/1"
44
45#define MD_TIME_LIFE_NORM (apr_time_from_sec(100 * MD_SECS_PER_DAY))
46#define MD_TIME_RENEW_WINDOW_DEF (apr_time_from_sec(33 * MD_SECS_PER_DAY))
47#define MD_TIME_WARN_WINDOW_DEF (apr_time_from_sec(10 * MD_SECS_PER_DAY))
48#define MD_TIME_OCSP_KEEP_NORM (apr_time_from_sec(7 * MD_SECS_PER_DAY))
49
50#define MD_OTHER "other"
51
52typedef enum {
53 MD_S_UNKNOWN = 0, /* MD has not been analysed yet */
54 MD_S_INCOMPLETE = 1, /* MD is missing necessary information, cannot go live */
55 MD_S_COMPLETE = 2, /* MD has all necessary information, can go live */
56 MD_S_EXPIRED_DEPRECATED = 3, /* deprecated */
57 MD_S_ERROR = 4, /* MD data is flawed, unable to be processed as is */
58 MD_S_MISSING_INFORMATION = 5, /* User has not agreed to ToS */
60
67
68typedef enum {
69 MD_RENEW_DEFAULT = -1, /* default value */
70 MD_RENEW_MANUAL, /* manually triggered renewal of certificate */
71 MD_RENEW_AUTO, /* automatic process performed by httpd */
72 MD_RENEW_ALWAYS, /* always renewed by httpd, even if not necessary */
74
75typedef struct md_t md_t;
76struct md_t {
77 const char *name; /* unique name of this MD */
78 struct apr_array_header_t *domains; /* all DNS names this MD includes */
79 struct apr_array_header_t *contacts; /* list of contact uris, e.g. mailto:xxx */
80
81 struct md_pkeys_spec_t *pks; /* specification for generating private keys */
82 md_timeslice_t *renew_window; /* time before expiration that starts renewal */
83 md_timeslice_t *warn_window; /* time before expiration that warnings are sent out */
84
85 const char *ca_proto; /* protocol used vs CA (e.g. ACME) */
86 struct apr_array_header_t *ca_urls; /* urls of CAs */
87 const char *ca_effective; /* url of CA used */
88 const char *ca_account; /* account used at CA */
89 const char *ca_agreement; /* accepted agreement uri between CA and user */
90 struct apr_array_header_t *ca_challenges; /* challenge types configured for this MD */
91 struct apr_array_header_t *cert_files; /* != NULL iff pubcerts explicitly configured */
92 struct apr_array_header_t *pkey_files; /* != NULL iff privkeys explicitly configured */
93 const char *ca_eab_kid; /* optional KEYID for external account binding */
94 const char *ca_eab_hmac; /* optional HMAC for external account binding */
95
96 const char *state_descr; /* description of state of NULL */
97
98 struct apr_array_header_t *acme_tls_1_domains; /* domains supporting "acme-tls/1" protocol */
99 const char *dns01_cmd; /* DNS challenge command, override global command */
100
101 const struct md_srv_conf_t *sc; /* server config where it was defined or NULL */
102 const char *defn_name; /* config file this MD was defined */
103 unsigned defn_line_number; /* line number of definition */
104 const char *configured_name; /* name this MD was configured with, if different */
105
106 int renew_mode; /* mode of obtaining credentials */
107 md_require_t require_https; /* Iff https: is required for this MD */
108 md_state_t state; /* state of this MD */
109 int transitive; /* != 0 iff VirtualHost names/aliases are auto-added */
110 int must_staple; /* certificates should set the OCSP Must Staple extension */
111 int stapling; /* if OCSP stapling is enabled */
112 int watched; /* if certificate is supervised (renew or expiration warning) */
113};
114
115#define MD_KEY_ACCOUNT "account"
116#define MD_KEY_ACME_TLS_1 "acme-tls/1"
117#define MD_KEY_ACTIVATION_DELAY "activation-delay"
118#define MD_KEY_ACTIVITY "activity"
119#define MD_KEY_AGREEMENT "agreement"
120#define MD_KEY_AUTHORIZATIONS "authorizations"
121#define MD_KEY_BITS "bits"
122#define MD_KEY_CA "ca"
123#define MD_KEY_CA_URL "ca-url"
124#define MD_KEY_CERT "cert"
125#define MD_KEY_CERT_FILES "cert-files"
126#define MD_KEY_CERTIFICATE "certificate"
127#define MD_KEY_CHALLENGE "challenge"
128#define MD_KEY_CHALLENGES "challenges"
129#define MD_KEY_CMD_DNS01 "cmd-dns-01"
130#define MD_KEY_DNS01_VERSION "cmd-dns-01-version"
131#define MD_KEY_COMPLETE "complete"
132#define MD_KEY_CONTACT "contact"
133#define MD_KEY_CONTACTS "contacts"
134#define MD_KEY_CSR "csr"
135#define MD_KEY_CURVE "curve"
136#define MD_KEY_DETAIL "detail"
137#define MD_KEY_DISABLED "disabled"
138#define MD_KEY_DIR "dir"
139#define MD_KEY_DOMAIN "domain"
140#define MD_KEY_DOMAINS "domains"
141#define MD_KEY_EAB "eab"
142#define MD_KEY_EAB_REQUIRED "externalAccountRequired"
143#define MD_KEY_ENTRIES "entries"
144#define MD_KEY_ERRORED "errored"
145#define MD_KEY_ERROR "error"
146#define MD_KEY_ERRORS "errors"
147#define MD_KEY_EXPIRES "expires"
148#define MD_KEY_FINALIZE "finalize"
149#define MD_KEY_FINISHED "finished"
150#define MD_KEY_FROM "from"
151#define MD_KEY_GOOD "good"
152#define MD_KEY_HMAC "hmac"
153#define MD_KEY_HTTP "http"
154#define MD_KEY_HTTPS "https"
155#define MD_KEY_ID "id"
156#define MD_KEY_IDENTIFIER "identifier"
157#define MD_KEY_KEY "key"
158#define MD_KEY_KID "kid"
159#define MD_KEY_KEYAUTHZ "keyAuthorization"
160#define MD_KEY_LAST "last"
161#define MD_KEY_LAST_RUN "last-run"
162#define MD_KEY_LOCATION "location"
163#define MD_KEY_LOG "log"
164#define MD_KEY_MDS "managed-domains"
165#define MD_KEY_MESSAGE "message"
166#define MD_KEY_MUST_STAPLE "must-staple"
167#define MD_KEY_NAME "name"
168#define MD_KEY_NEXT_RUN "next-run"
169#define MD_KEY_NOTIFIED "notified"
170#define MD_KEY_NOTIFIED_RENEWED "notified-renewed"
171#define MD_KEY_OCSP "ocsp"
172#define MD_KEY_OCSPS "ocsps"
173#define MD_KEY_ORDERS "orders"
174#define MD_KEY_PERMANENT "permanent"
175#define MD_KEY_PKEY "privkey"
176#define MD_KEY_PKEY_FILES "pkey-files"
177#define MD_KEY_PROBLEM "problem"
178#define MD_KEY_PROTO "proto"
179#define MD_KEY_READY "ready"
180#define MD_KEY_REGISTRATION "registration"
181#define MD_KEY_RENEW "renew"
182#define MD_KEY_RENEW_AT "renew-at"
183#define MD_KEY_RENEW_MODE "renew-mode"
184#define MD_KEY_RENEWAL "renewal"
185#define MD_KEY_RENEWING "renewing"
186#define MD_KEY_RENEW_WINDOW "renew-window"
187#define MD_KEY_REQUIRE_HTTPS "require-https"
188#define MD_KEY_RESOURCE "resource"
189#define MD_KEY_RESPONSE "response"
190#define MD_KEY_REVOKED "revoked"
191#define MD_KEY_SERIAL "serial"
192#define MD_KEY_SHA256_FINGERPRINT "sha256-fingerprint"
193#define MD_KEY_STAPLING "stapling"
194#define MD_KEY_STATE "state"
195#define MD_KEY_STATE_DESCR "state-descr"
196#define MD_KEY_STATUS "status"
197#define MD_KEY_STORE "store"
198#define MD_KEY_SUBPROBLEMS "subproblems"
199#define MD_KEY_TEMPORARY "temporary"
200#define MD_KEY_TOS "termsOfService"
201#define MD_KEY_TOKEN "token"
202#define MD_KEY_TOTAL "total"
203#define MD_KEY_TRANSITIVE "transitive"
204#define MD_KEY_TYPE "type"
205#define MD_KEY_UNKNOWN "unknown"
206#define MD_KEY_UNTIL "until"
207#define MD_KEY_URL "url"
208#define MD_KEY_URLS "urls"
209#define MD_KEY_URI "uri"
210#define MD_KEY_VALID "valid"
211#define MD_KEY_VALID_FROM "valid-from"
212#define MD_KEY_VALUE "value"
213#define MD_KEY_VERSION "version"
214#define MD_KEY_WATCHED "watched"
215#define MD_KEY_WHEN "when"
216#define MD_KEY_WARN_WINDOW "warn-window"
217
218/* Check if a string member of a new MD (n) has
219 * a value and if it differs from the old MD o
220 */
221#define MD_VAL_UPDATE(n,o,s) ((n)->s != (o)->s)
222#define MD_SVAL_UPDATE(n,o,s) ((n)->s && (!(o)->s || strcmp((n)->s, (o)->s)))
223
227int md_contains(const md_t *md, const char *domain, int case_sensitive);
228
232int md_domains_overlap(const md_t *md1, const md_t *md2);
233
237int md_equal_domains(const md_t *md1, const md_t *md2, int case_sensitive);
238
242int md_contains_domains(const md_t *md1, const md_t *md2);
243
247const char *md_common_name(const md_t *md1, const md_t *md2);
248
253
257md_t *md_get_by_name(struct apr_array_header_t *mds, const char *name);
258
262md_t *md_get_by_domain(struct apr_array_header_t *mds, const char *domain);
263
268md_t *md_get_by_dns_overlap(struct apr_array_header_t *mds, const md_t *md);
269
274
278md_t *md_create(apr_pool_t *p, struct apr_array_header_t *domains);
279
283md_t *md_clone(apr_pool_t *p, const md_t *src);
284
288md_t *md_copy(apr_pool_t *p, const md_t *src);
289
295struct md_json_t *md_to_json(const md_t *md, apr_pool_t *p);
296md_t *md_from_json(struct md_json_t *json, apr_pool_t *p);
297
301struct md_json_t *md_to_public_json(const md_t *md, apr_pool_t *p);
302
303int md_is_covered_by_alt_names(const md_t *md, const struct apr_array_header_t* alt_names);
304
305/* how many certificates this domain has/will eventually have. */
306int md_cert_count(const md_t *md);
307
308const char *md_get_ca_name_from_url(apr_pool_t *p, const char *url);
309apr_status_t md_get_ca_url_from_name(const char **purl, apr_pool_t *p, const char *name);
310
311/**************************************************************************************************/
312/* notifications */
313
314typedef apr_status_t md_job_notify_cb(struct md_job_t *job, const char *reason,
315 struct md_result_t *result, apr_pool_t *p, void *baton);
316
317/**************************************************************************************************/
318/* domain credentials */
319
322 struct apr_array_header_t *certs; /* chain of const md_cert*, leaf cert first */
323 struct apr_array_header_t *alt_names; /* alt-names of leaf cert */
324 const char *cert_file; /* file path of chain */
325 const char *key_file; /* file path of key for leaf cert */
326};
327
328#define MD_OK(c) (APR_SUCCESS == (rv = c))
329
330#endif /* mod_md_md_h */
APR Time Library.
ap_vhost_iterate_conn_cb void * baton
Definition http_vhost.h:87
const char * src
Definition apr_encode.h:167
const char * url
Definition apr_escape.h:120
const char int case_sensitive
apr_size_t size
int apr_status_t
Definition apr_errno.h:44
apr_array_header_t ** result
int reason
int md_equal_domains(const md_t *md1, const md_t *md2, int case_sensitive)
Definition md_core.c:121
int md_cert_count(const md_t *md)
Definition md_core.c:187
apr_status_t md_job_notify_cb(struct md_job_t *job, const char *reason, struct md_result_t *result, apr_pool_t *p, void *baton)
Definition md.h:314
int md_is_covered_by_alt_names(const md_t *md, const struct apr_array_header_t *alt_names)
Definition md_core.c:86
md_state_t
Definition md.h:52
@ MD_S_INCOMPLETE
Definition md.h:54
@ MD_S_ERROR
Definition md.h:57
@ MD_S_COMPLETE
Definition md.h:55
@ MD_S_EXPIRED_DEPRECATED
Definition md.h:56
@ MD_S_UNKNOWN
Definition md.h:53
@ MD_S_MISSING_INFORMATION
Definition md.h:58
md_t * md_clone(apr_pool_t *p, const md_t *src)
Definition md_core.c:228
md_t * md_get_by_name(struct apr_array_header_t *mds, const char *name)
Definition md_core.c:151
const char * md_common_name(const md_t *md1, const md_t *md2)
Definition md_core.c:43
md_t * md_get_by_domain(struct apr_array_header_t *mds, const char *domain)
Definition md_core.c:163
int md_domains_overlap(const md_t *md1, const md_t *md2)
Definition md_core.c:61
md_t * md_create(apr_pool_t *p, struct apr_array_header_t *domains)
Definition md_core.c:196
md_t * md_copy(apr_pool_t *p, const md_t *src)
Definition md_core.c:210
apr_size_t md_common_name_count(const md_t *md1, const md_t *md2)
Definition md_core.c:66
md_t * md_get_by_dns_overlap(struct apr_array_header_t *mds, const md_t *md)
Definition md_core.c:175
struct md_json_t * md_to_json(const md_t *md, apr_pool_t *p)
Definition md_core.c:268
const char * md_get_ca_name_from_url(apr_pool_t *p, const char *url)
Definition md_core.c:417
apr_status_t md_get_ca_url_from_name(const char **purl, apr_pool_t *p, const char *name)
Definition md_core.c:433
md_renew_mode_t
Definition md.h:68
@ MD_RENEW_DEFAULT
Definition md.h:69
@ MD_RENEW_AUTO
Definition md.h:71
@ MD_RENEW_MANUAL
Definition md.h:70
@ MD_RENEW_ALWAYS
Definition md.h:72
int md_contains_domains(const md_t *md1, const md_t *md2)
Definition md_core.c:136
md_require_t
Definition md.h:61
@ MD_REQUIRE_UNSET
Definition md.h:62
@ MD_REQUIRE_OFF
Definition md.h:63
@ MD_REQUIRE_TEMPORARY
Definition md.h:64
@ MD_REQUIRE_PERMANENT
Definition md.h:65
md_t * md_from_json(struct md_json_t *json, apr_pool_t *p)
Definition md_core.c:325
int md_contains(const md_t *md, const char *domain, int case_sensitive)
Definition md_core.c:35
struct md_json_t * md_to_public_json(const md_t *md, apr_pool_t *p)
Definition md_core.c:391
md_t * md_create_empty(apr_pool_t *p)
Definition md_core.c:103
static const char * alt_names(apr_array_header_t *domains, apr_pool_t *p)
Definition md_crypt.c:1692
apr_pool_t * p
Definition md_event.c:32
char * name
const char * key_file
Definition md.h:325
struct apr_array_header_t * certs
Definition md.h:322
const char * cert_file
Definition md.h:324
struct apr_array_header_t * alt_names
Definition md.h:323
Definition md.h:76
const char * name
Definition md.h:77
md_timeslice_t * renew_window
Definition md.h:82
int transitive
Definition md.h:109
struct apr_array_header_t * domains
Definition md.h:78
const struct md_srv_conf_t * sc
Definition md.h:101
const char * ca_eab_hmac
Definition md.h:94
md_timeslice_t * warn_window
Definition md.h:83
struct apr_array_header_t * acme_tls_1_domains
Definition md.h:98
md_require_t require_https
Definition md.h:107
struct apr_array_header_t * pkey_files
Definition md.h:92
const char * defn_name
Definition md.h:102
unsigned defn_line_number
Definition md.h:103
const char * ca_effective
Definition md.h:87
md_state_t state
Definition md.h:108
int must_staple
Definition md.h:110
const char * ca_proto
Definition md.h:85
struct apr_array_header_t * ca_urls
Definition md.h:86
int watched
Definition md.h:112
struct md_pkeys_spec_t * pks
Definition md.h:81
const char * ca_eab_kid
Definition md.h:93
const char * ca_account
Definition md.h:88
const char * ca_agreement
Definition md.h:89
const char * configured_name
Definition md.h:104
struct apr_array_header_t * contacts
Definition md.h:79
int renew_mode
Definition md.h:106
int stapling
Definition md.h:111
struct apr_array_header_t * cert_files
Definition md.h:91
const char * state_descr
Definition md.h:96
struct apr_array_header_t * ca_challenges
Definition md.h:90
const char * dns01_cmd
Definition md.h:99