xref: /openbsd/usr.sbin/acme-client/parse.h (revision 57e2f549)
1 /*	$OpenBSD: parse.h,v 1.9 2017/11/27 16:53:04 sthen Exp $ */
2 /*
3  * Copyright (c) 2016 Sebastian Benoit <benno@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 #ifndef PARSE_H
18 #define PARSE_H
19 
20 #include <sys/queue.h>
21 
22 #define AUTH_MAXLEN	120	/* max length of an authority_c name */
23 #define DOMAIN_MAXLEN	255	/* max len of a domain name (rfc2181) */
24 
25 /*
26  * XXX other size limits needed?
27  * limit all paths to PATH_MAX
28  */
29 
30 struct authority_c {
31 	TAILQ_ENTRY(authority_c)	 entry;
32 	char		       	*name;
33 	char		       	*api;
34 	char		       	*account;
35 };
36 
37 struct domain_c {
38 	TAILQ_ENTRY(domain_c)	 entry;
39 	TAILQ_HEAD(, altname_c)	altname_list;
40 	int			altname_count;
41 	char		       	*domain;
42 	char		       	*key;
43 	char		       	*cert;
44 	char			*chain;
45 	char			*fullchain;
46 	char		       	*auth;
47 	char		       	*challengedir;
48 };
49 
50 struct altname_c {
51 	TAILQ_ENTRY(altname_c)	 entry;
52 	char		       	*domain;
53 };
54 
55 struct keyfile {
56 	LIST_ENTRY(keyfile)	 entry;
57 	char			*name;
58 };
59 
60 #define ACME_OPT_VERBOSE	0x00000001
61 #define ACME_OPT_NEWACCT	0x00000002
62 #define ACME_OPT_NEWDKEY	0x00000004
63 #define ACME_OPT_CHECK		0x00000008
64 
65 struct acme_conf {
66 	int			 opts;
67 	TAILQ_HEAD(, authority_c) authority_list;
68 	TAILQ_HEAD(, domain_c)	 domain_list;
69 	LIST_HEAD(, keyfile)	 used_key_list;
70 };
71 
72 struct acme_conf	*parse_config(const char *, int);
73 int			 cmdline_symset(char *);
74 
75 /* use these to find a authority or domain by name */
76 struct authority_c	*authority_find(struct acme_conf *, char *);
77 struct authority_c	*authority_find0(struct acme_conf *);
78 struct domain_c		*domain_find(struct acme_conf *, char *);
79 
80 int			 domain_valid(const char *);
81 
82 #endif /* PARSE_H */
83