1
0
mirror of https://github.com/openbsd/src.git synced 2026-05-01 09:37:02 +00:00

only include port numbers in Host headers when it's not 443.

step-ca has a teary if you include the port in the Host header, but
pebble gets confused if you don't. florian says "I can't see anything
in RFC9110 7.2 that suggests sending a port in the host header is
wrong", so we're pretty sure step-ca is doing the wrong thing, but
it's also pretty easy to be accomodating by omitting the port if
the https request is on port 443. just don't talk to step-ca on a
non standard port i guess.

ok sthen@ florian@
This commit is contained in:
dlg
2025-11-18 00:54:11 +00:00
parent 8cc4379780
commit ad53811e7f

View File

@@ -1,4 +1,4 @@
/* $Id: http.c,v 1.35 2025/06/10 16:00:28 florian Exp $ */
/* $Id: http.c,v 1.36 2025/11/18 00:54:11 dlg Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -298,31 +298,40 @@ http_open(const struct http *http, int headreq, const void *p, size_t psz)
char *req;
int c;
struct httpxfer *trans;
char port[16] = "";
if (http->port != 443) {
int rv = snprintf(port, sizeof(port), ":%d", http->port);
if (rv == -1 || (size_t)rv >= sizeof(port)) {
warnx("%s port printf", __func__);
return NULL;
}
}
if (p == NULL) {
if (headreq)
c = asprintf(&req,
"HEAD %s HTTP/1.0\r\n"
"Host: %s:%d\r\n"
"Host: %s%s\r\n"
"User-Agent: OpenBSD-acme-client\r\n"
"\r\n",
http->path, http->host, http->port);
http->path, http->host, port);
else
c = asprintf(&req,
"GET %s HTTP/1.0\r\n"
"Host: %s:%d\r\n"
"Host: %s%s\r\n"
"User-Agent: OpenBSD-acme-client\r\n"
"\r\n",
http->path, http->host, http->port);
http->path, http->host, port);
} else {
c = asprintf(&req,
"POST %s HTTP/1.0\r\n"
"Host: %s:%d\r\n"
"Host: %s%s\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, http->port, psz);
http->path, http->host, port, psz);
}
if (c == -1) {