Commit 8e993fe9 authored by Martin Vahlensieck's avatar Martin Vahlensieck Committed by Timo Teräs

Use correct port when redirected

If server redirects from http to https, libfetch detects this, but
wrongly uses the old url scheme to determine the port. This subsequently
leads to the following OpenSSL error:

139741541575496:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:331:

Using the new scheme fixes this.  This error message comes from trying
to connect to port 80 with TLS, it can also be observed by issuing
  $ openssl s_client -connect alpinelinux.org:80

This bug was introduced in commit:
7158474f libfetch: keep http auth only if redirect is for the same host
parent 361eb063
Pipeline #75153 passed with stage
in 1 minute and 9 seconds
......@@ -1065,7 +1065,7 @@ http_request(struct url *URL, const char *op, struct url_stat *us,
goto ouch;
}
if (!new->port)
new->port = fetch_default_port(url->scheme);
new->port = fetch_default_port(new->scheme);
if (!new->user[0] && !new->pwd[0] &&
new->port == url->port &&
strcmp(new->scheme, url->scheme) == 0 &&
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment