summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/acme-client/extern.h10
-rw-r--r--usr.sbin/acme-client/json.c16
-rw-r--r--usr.sbin/acme-client/netproc.c8
3 files changed, 20 insertions, 14 deletions
diff --git a/usr.sbin/acme-client/extern.h b/usr.sbin/acme-client/extern.h
index dda2edde484..eaaae0cfb1d 100644
--- a/usr.sbin/acme-client/extern.h
+++ b/usr.sbin/acme-client/extern.h
@@ -1,4 +1,4 @@
-/* $Id: extern.h,v 1.9 2017/11/27 01:58:52 florian Exp $ */
+/* $Id: extern.h,v 1.10 2019/01/31 15:55:48 benno Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -146,11 +146,17 @@ enum comm {
* (presumably!) local machine to an ACME connection; and a URI, to
* which we must connect to verify the token.
*/
+enum chngstatus {
+ CHNG_INVALID = -1,
+ CHNG_PENDING = 0,
+ CHNG_VALID = 1
+};
+
struct chng {
char *uri; /* uri on ACME server */
char *token; /* token we must offer */
size_t retry; /* how many times have we tried */
- int status; /* challenge accepted? */
+ enum chngstatus status; /* challenge accepted? */
};
/*
diff --git a/usr.sbin/acme-client/json.c b/usr.sbin/acme-client/json.c
index d985e200e8d..a86990c59a4 100644
--- a/usr.sbin/acme-client/json.c
+++ b/usr.sbin/acme-client/json.c
@@ -1,4 +1,4 @@
-/* $Id: json.c,v 1.10 2017/11/27 01:58:52 florian Exp $ */
+/* $Id: json.c,v 1.11 2019/01/31 15:55:48 benno Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -332,23 +332,23 @@ json_free_challenge(struct chng *p)
* Parse the response from the ACME server when we're waiting to see
* whether the challenge has been ok.
*/
-int
+enum chngstatus
json_parse_response(struct jsmnn *n)
{
char *resp;
- int rc;
+ enum chngstatus rc;
if (n == NULL)
- return -1;
+ return CHNG_INVALID;
if ((resp = json_getstr(n, "status")) == NULL)
- return -1;
+ return CHNG_INVALID;
if (strcmp(resp, "valid") == 0)
- rc = 1;
+ rc = CHNG_VALID;
else if (strcmp(resp, "pending") == 0)
- rc = 0;
+ rc = CHNG_PENDING;
else
- rc = -1;
+ rc = CHNG_INVALID;
free(resp);
return rc;
diff --git a/usr.sbin/acme-client/netproc.c b/usr.sbin/acme-client/netproc.c
index e5845401862..b6067a7d6b3 100644
--- a/usr.sbin/acme-client/netproc.c
+++ b/usr.sbin/acme-client/netproc.c
@@ -1,4 +1,4 @@
-/* $Id: netproc.c,v 1.19 2018/11/29 14:25:07 tedu Exp $ */
+/* $Id: netproc.c,v 1.20 2019/01/31 15:55:48 benno Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -454,7 +454,7 @@ dochngresp(struct conn *c, const struct chng *chng, const char *th)
static int
dochngcheck(struct conn *c, struct chng *chng)
{
- int cc;
+ enum chngstatus cc;
long lc;
struct jsmnn *j;
@@ -477,7 +477,7 @@ dochngcheck(struct conn *c, struct chng *chng)
json_free(j);
return 0;
} else if (cc > 0)
- chng->status = 1;
+ chng->status = CHNG_VALID;
json_free(j);
return 1;
@@ -760,7 +760,7 @@ netproc(int kfd, int afd, int Cfd, int cfd, int dfd, int rfd,
*/
for (i = 0; i < altsz; i++) {
- if (chngs[i].status == 1)
+ if (chngs[i].status == CHNG_VALID)
continue;
if (chngs[i].retry++ >= RETRY_MAX) {