From: Florian Obser Subject: acme-client(1): port numbers in API urls To: tech Date: Sun, 08 Jun 2025 15:07:43 +0200 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 #include #include +#include #include #include #include @@ -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.