Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to non-standard HTTPS port #23

Closed
peloy opened this issue Sep 7, 2017 · 7 comments
Closed

Cannot connect to non-standard HTTPS port #23

peloy opened this issue Sep 7, 2017 · 7 comments

Comments

@peloy
Copy link

peloy commented Sep 7, 2017

My Cisco ASA is configured to terminate SSL VPN connection on port 4443. Android OpenConnect (latest version from the Google Play store) is not able to connect. The full OpenConnect log is in the screenshot mentioned below but the ASA is apparently returning the message "Invalid host entry. Please re-enter".

OpenConnect 7.08 running on Linux is able to connect with no issues.

On the ASA side, with lots of debugs enabled, I see this for a bad connection:

fw# sh debug
debug http  enabled at level 255 
debug webvpn  enabled at level 255 
debug webvpn html enabled at level 255 
debug webvpn request enabled at level 255 
debug webvpn response enabled at level 255 
debug webvpn url enabled at level 255 
debug webvpn xml enabled at level 255 
debug webvpn anyconnect enabled at level 255 
debug webvpn cstp-auth enabled at level 255 
debug webvpn session enabled at level 255 
debug webvpn task enabled at level 255 

fw# 
fw# 
fw# #0x00002aaac47281f0 (POST). Request line:/GROUPNAME
#0x00002aaac47281f0 (Response) Start
#0x00002aaac47281f0 File to execute: /+CSCOU+/anyconnect_wrong_url.html
#0x00002aaac47281f0 (Response) Open handler file [/+CSCOU+/anyconnect_wrong_url.html]
#0x00002aaac47281f0 (Response) Processing LUA page.
#0x00002aaac47281f0 (Response) Finish, connection keep-alive.

(And that's it; I only have the OpenConnect log on the phone as additional information.)

A good connection from Linux running OpenConnect 7.08 shows this:

fw# #0x00002aaac4728970 (POST). Request line:/GROUPNAME
#0x00002aaac4728970 (Response) Start
#0x00002aaac4728970 File to execute: /CSCOSSLC/config-auth
#0x00002aaac4728970 (Response) Open handler file [/CSCOSSLC/config-auth]
#0x00002aaac4728970 (Response) Processing LUA page.
Certificate mapping found for webvpn group GROUPNAME
#0x00002aaac4728970 (Response) Finish, connection keep-alive.
#0x00002aaac4728970 (POST). Request line:/GROUPNAME
#0x00002aaac4728970 (Response) Start
#0x00002aaac4728970 File to execute: /CSCOSSLC/config-auth
#0x00002aaac4728970 (Response) Open handler file [/CSCOSSLC/config-auth]
#0x00002aaac4728970 (Response) Processing LUA page.
Certificate mapping found for webvpn group GROUPNAME
Public archive directives retrieved from cache for index 2.
#0x00002aaac4728970 (Response) Finish, connection keep-alive.
#0x00002aaac4728970 (POST). Request line:/
#0x00002aaac4728970 (Response) Start
#0x00002aaac4728970 File to execute: /CSCOSSLC/config-auth
#0x00002aaac4728970 (Response) Open handler file [/CSCOSSLC/config-auth]
#0x00002aaac4728970 (Response) Processing LUA page.
[Rest of successful connection log removed.]

screenshot_20170907-115124

Any idea about what could be wrong? Perhaps the wrong Host: header is being passed? It should be "Host: vpn.xxxxx.com:4443", right?

Thanks in advance for any insight.

@cernekee
Copy link
Owner

cernekee commented Sep 7, 2017

Possibly related:

https://serverfault.com/questions/771645/openconnect-cannot-connect-to-anyconnect-vpn-group-using-g
https://quickview.cloudapps.cisco.com/quickview/bug/CSCuc16678

I wonder if the <group-access> field has the wrong value if a port number is specified. If possible, try experimenting with v7.04 of the command-line openconnect client on Linux or OSX, as that will be easier than repeatedly modifying the library and rebuilding for Android.

@peloy
Copy link
Author

peloy commented Sep 9, 2017

Hi Kevin,

Given that the debugs on the ASA are lacking, I set up a MitM proxy to be able to see the traffic sent by OpenConnect on Android and I think the problem is this:

OpenConnect v7.08 running on Linux sends a POST request with:

Host: vpn.example.com:4443

and

<group-access>https://vpn.example.com:4443/GROUPNAME</group-access>

in the body of the POST.

OpenConnect running on Android sends:

Host: vpn.example.com

(i.e. no port), and:

<group-access>https://vpn.example.com/GROUPNAME</group-access>

(Again, no port.)

There is only one HTTP request made by OpenConnect, and it's immediately rejected by the ASA with that "Invalid host entry. Please re-enter" response.

Is OpenConnect for Android based on OpenConnect v7.04? If so, is it too difficult to make OpenConnect for Android use OpenConnect v7.08 as it seems to be working fine on that version? I can try to identify a commit that (possibly) fixed this behavior, if that helps.

Cheers!

@cernekee
Copy link
Owner

Is OpenConnect for Android based on OpenConnect v7.04? If so, is it too difficult to make OpenConnect for Android use OpenConnect v7.08

Some additional work will be needed to use libopenconnect 7.08 on Android. It is on my TODO list but it isn't currently a high priority. It would be helpful to understand whether this issue is something that is fixed by upgrading from 7.04 to 7.08, or if it is something specific to Android on 7.04.

@peloy
Copy link
Author

peloy commented Sep 10, 2017

I am pretty sure this issue will be fixed with an upgrade to a more recent OpenConnect version...

For the "<group-access>" XML node, the non-standard port is appended to the URI in auth.c:xmlpost_initial_req():

    buf_append(url_buf, "https://%s", vpninfo->hostname);
    if (vpninfo->port != 443)
            buf_append(url_buf, ":%d", vpninfo->port);

This part of the code was re-worked because it's different in v7.04:

if (vpninfo->urlpath)
	result = asprintf(&url, "https://%s/%s", vpninfo->hostname, vpninfo->urlpath);
else
	result = asprintf(&url, "https://%s", vpninfo->hostname);

(No non-standard port is appended.)

Same thing for the "Host:" HTTP header: In v7.08's cstp.c:start_cstp_connection() the code is:

    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);

(i.e. non-standard port appended to the host.)

but in v7.04's cstp.c:start_cstp_connection() the code is simply:

buf_append(reqbuf, "Host: %s\r\n", vpninfo->hostname);

@cernekee
Copy link
Owner

cernekee commented Feb 4, 2018

The master branch is now based on v7.08 + additional fixes. Can you retest?

Here's a debug APK, if needed:

https://storage.googleapis.com/cernekee-travis/ics-openconnect/OpenConnect-debug.apk

@peloy
Copy link
Author

peloy commented Mar 19, 2018 via email

@dlenski
Copy link
Collaborator

dlenski commented Jun 5, 2019

Closed per #23 (comment)

@dlenski dlenski closed this as completed Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants