Skip to content

Commit

Permalink
Patch for servers that do not listen on TCP 443
Browse files Browse the repository at this point in the history
Signed-off-by: Mathias Schuepany <mathias.schuepany@catalysts.cc>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Mathias Schuepany authored and David Woodhouse committed Aug 25, 2016
1 parent 9048cda commit 074da25
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
22 changes: 17 additions & 5 deletions auth.c
Expand Up @@ -778,10 +778,18 @@ static int xmlpost_initial_req(struct openconnect_info *vpninfo,
if (!doc)
return -ENOMEM;

if (vpninfo->urlpath)
result = asprintf(&url, "https://%s/%s", vpninfo->hostname, vpninfo->urlpath);
else
result = asprintf(&url, "https://%s", vpninfo->hostname);
if (vpninfo->urlpath) {
if (vpninfo->port != 443)
result = asprintf(&url, "https://%s:%d/%s", vpninfo->hostname, vpninfo->port, vpninfo->urlpath);
else
result = asprintf(&url, "https://%s/%s", vpninfo->hostname, vpninfo->urlpath);
}
else {
if (vpninfo->port != 443)
result = asprintf(&url, "https://%s:%d", vpninfo->hostname, vpninfo->port);
else
result = asprintf(&url, "https://%s", vpninfo->hostname);
}

if (result == -1)
goto bad;
Expand Down Expand Up @@ -919,7 +927,11 @@ static int fetch_config(struct openconnect_info *vpninfo)
}

buf = buf_alloc();
buf_append(buf, "GET %s HTTP/1.1\r\n", vpninfo->profile_url);

if (vpninfo->port != 443)
buf_append(buf, "GET %s:%d HTTP/1.1\r\n", vpninfo->profile_url, vpninfo->port);
else
buf_append(buf, "GET %s HTTP/1.1\r\n", vpninfo->profile_url);
cstp_common_headers(vpninfo, buf);
if (vpninfo->xmlpost)
buf_append(buf, "Cookie: webvpn=%s\r\n", vpninfo->cookie);
Expand Down
5 changes: 4 additions & 1 deletion cstp.c
Expand Up @@ -199,7 +199,10 @@ static int start_cstp_connection(struct openconnect_info *vpninfo)

reqbuf = buf_alloc();
buf_append(reqbuf, "CONNECT /CSCOSSLC/tunnel HTTP/1.1\r\n");
buf_append(reqbuf, "Host: %s\r\n", vpninfo->hostname);
if (vpninfo->port != 443)
buf_append(reqbuf, "Host: %s:%d\r\n", vpninfo->hostname, vpninfo->port);
else
buf_append(reqbuf, "Host: %s\r\n", vpninfo->hostname);
buf_append(reqbuf, "User-Agent: %s\r\n", vpninfo->useragent);
buf_append(reqbuf, "Cookie: webvpn=%s\r\n", vpninfo->cookie);
buf_append(reqbuf, "X-CSTP-Version: 1\r\n");
Expand Down
10 changes: 8 additions & 2 deletions http.c
Expand Up @@ -1295,7 +1295,10 @@ static int process_http_proxy(struct openconnect_info *vpninfo)
retry:
reqbuf = buf_alloc();
buf_append(reqbuf, "CONNECT %s:%d HTTP/1.1\r\n", vpninfo->hostname, vpninfo->port);
buf_append(reqbuf, "Host: %s\r\n", vpninfo->hostname);
if (vpninfo->port == 443)
buf_append(reqbuf, "Host: %s\r\n", vpninfo->hostname);
else
buf_append(reqbuf, "Host: %s:%d\r\n", vpninfo->hostname, vpninfo->port);
buf_append(reqbuf, "User-Agent: %s\r\n", vpninfo->useragent);
buf_append(reqbuf, "Proxy-Connection: keep-alive\r\n");
buf_append(reqbuf, "Connection: keep-alive\r\n");
Expand Down Expand Up @@ -1428,7 +1431,10 @@ void http_common_headers(struct openconnect_info *vpninfo, struct oc_text_buf *b
{
struct oc_vpn_option *opt;

buf_append(buf, "Host: %s\r\n", vpninfo->hostname);
if (vpninfo->port == 443)
buf_append(buf, "Host: %s\r\n", vpninfo->hostname);
else
buf_append(buf, "Host: %s:%d\r\n", vpninfo->hostname, vpninfo->port);
buf_append(buf, "User-Agent: %s\r\n", vpninfo->useragent);

if (vpninfo->cookies) {
Expand Down

0 comments on commit 074da25

Please sign in to comment.