Download raw body.
acme-client(1): port numbers in API urls
This is needed to test against the "pebble" let's encrypt test server.
OK?
diff --git http.c http.c
index 08a195e7d92..c996a1d519f 100644
--- http.c
+++ http.c
@@ -299,26 +299,26 @@ http_open(const struct http *http, int headreq, const void *p, size_t psz)
if (headreq)
c = asprintf(&req,
"HEAD %s HTTP/1.0\r\n"
- "Host: %s\r\n"
+ "Host: %s:%d\r\n"
"User-Agent: OpenBSD-acme-client\r\n"
"\r\n",
- http->path, http->host);
+ http->path, http->host, http->port);
else
c = asprintf(&req,
"GET %s HTTP/1.0\r\n"
- "Host: %s\r\n"
+ "Host: %s:%d\r\n"
"User-Agent: OpenBSD-acme-client\r\n"
"\r\n",
- http->path, http->host);
+ http->path, http->host, http->port);
} else {
c = asprintf(&req,
"POST %s HTTP/1.0\r\n"
- "Host: %s\r\n"
+ "Host: %s:%d\r\n"
"Content-Length: %zu\r\n"
"Content-Type: application/jose+json\r\n"
"User-Agent: OpenBSD-acme-client\r\n"
"\r\n",
- http->path, http->host, psz);
+ http->path, http->host, http->port, psz);
}
if (c == -1) {
diff --git netproc.c netproc.c
index a1e8566bedf..3517868564e 100644
--- netproc.c
+++ netproc.c
@@ -19,6 +19,7 @@
#include <ctype.h>
#include <err.h>
#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -106,6 +107,27 @@ url2host(const char *host, short *port, char **path)
return NULL;
}
+ /* extract port */
+ if ((ep = strchr(url, ':')) != NULL) {
+ const char *errstr;
+ char *p = strdup(ep + 1);
+ if (p == NULL) {
+ warn("strdup");
+ free(url);
+ return NULL;
+ }
+ *ep = '\0';
+ *port = strtonum(p, 1, USHRT_MAX, &errstr);
+ if (errstr != NULL) {
+ warn("port is %s: %s", errstr, p);
+ free(url);
+ free(p);
+ return NULL;
+ }
+ free(p);
+
+ }
+
return url;
}
--
In my defence, I have been left unsupervised.
acme-client(1): port numbers in API urls