]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
4 years agomake F5 and Fortinet tests go through config-pulling (up to the point of tunnel conne...
Daniel Lenski [Mon, 22 Feb 2021 02:44:22 +0000 (18:44 -0800)]
make F5 and Fortinet tests go through config-pulling (up to the point of tunnel connection), rather than stopping after authentication

The fake servers don't actually implement the tunnel, but they do implement
the pre-tunnel configuration endpoints, and then simulate a "cookie rejected"
response upon tunnel connection.

OpenConnect distinguishes “cookie rejected” errors via an exit status of 2,
whereas any other failure results in an exit status of 1.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd auth-f5 tests
Daniel Lenski [Sun, 21 Feb 2021 23:02:44 +0000 (15:02 -0800)]
add auth-f5 tests

This tests OpenConnect's ability to authenticate with a (fake) F5
server, using username+password (the only option that OpenConnect
currently supports).

The fake F5 authentication server requires python3 and Flask.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd auth-fortinet tests
Daniel Lenski [Sun, 21 Feb 2021 23:02:44 +0000 (15:02 -0800)]
add auth-fortinet tests

This tests OpenConnect's ability to authenticate with a (fake) Fortinet
server, using all of the options that OpenConnect currently supports
(username+password, username+password+token, non-default realm).

The fake Fortinet authentication server requires Python 3.6 and Flask.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd openconnect__strchrnul function to compat.c
Daniel Lenski [Sat, 20 Feb 2021 17:39:07 +0000 (09:39 -0800)]
add openconnect__strchrnul function to compat.c

GNU strchrnul() is trivial to implement, and makes a bunch of string parsing
functions simpler and less error-prone.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet's realm parameter comes from the URL-path
Daniel Lenski [Fri, 19 Feb 2021 05:14:03 +0000 (21:14 -0800)]
Fortinet's realm parameter comes from the URL-path

See an example at https://github.com/adrienverge/openfortivpn/issues/827

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: parse <split-dns> domains and DNS servers from config
Daniel Lenski [Fri, 19 Feb 2021 04:14:00 +0000 (20:14 -0800)]
Fortinet: parse <split-dns> domains and DNS servers from config

Chimped config containing these settings from
https://github.com/adrienverge/openfortivpn/issues/824#issuecomment-764641406.

This doesn't actually *do* anything with the settings yet.

See https://github.com/dlenski/openconnect/issues/151 and
https://gitlab.com/openconnect/openconnect/-/merge_requests/132 for
discussion about split-DNS.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoattempt to implement Fortinet challenge-based 2FA (ping #225)
Daniel Lenski [Thu, 18 Feb 2021 03:27:10 +0000 (19:27 -0800)]
attempt to implement Fortinet challenge-based 2FA (ping #225)

2FA involves reading a bunch of values from the initial response and
parroting them back, along with changing the 'credential' field to 'code'.

This is based on Openfortivpn's implementation
(https://github.com/adrienverge/openfortivpn/blob/master/src/http.c#L711-L754),
and has been tested for basic correctness against a toy HTTPS server that
gives responses with the right format.

Still to do:

- Another one-time password mode: https://github.com/adrienverge/openfortivpn/blob/master/src/http.c#L672-L679, https://github.com/adrienverge/openfortivpn/commit/61dd4fcbbfe1dd89b95081e7d5f5c3e933d7897a
- There's a mobile-app-based "push" mode: https://github.com/adrienverge/openfortivpn/commit/2f16d964560d9b00acbf7bfc7131a0ac40c688f2

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agosimpler fortinet_obtain_cookie()
Daniel Lenski [Thu, 18 Feb 2021 03:23:36 +0000 (19:23 -0800)]
simpler fortinet_obtain_cookie()

Just build a static form, containing two fields ('username', 'credential')
like GP and F5.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoofficial Forticlient doesn't 'GET /remote/index', so let's not
Daniel Lenski [Wed, 10 Feb 2021 05:41:18 +0000 (21:41 -0800)]
official Forticlient doesn't 'GET /remote/index', so let's not

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoimplement fortinet_obtain_cookie
Daniel Lenski [Mon, 8 Feb 2021 01:49:10 +0000 (17:49 -0800)]
implement fortinet_obtain_cookie

Fortinet uses HTML-based login forms, similar to Juniper's, resulting in an SVPNCOOKIE.

Believe it or not, they're even more badly designed than Juniper's forms:

1. Inconsistent use of HTTP redirects ('Location' header) vs. Javascript-only redirects
2. Significant <input> fields that aren't actually nested within the <form> tag.
3. Misleading HTTP 405 status ("Method Not Allowed") after incorrect credentials are entered.
4. No apparent way to determine the allowed values for the realm field.
   (Though various articles floating around suggest it comes from the URL-path entry point,
   from which I assume it's triggered by JavaScript.)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: assume default route if no split routes received
Daniel Lenski [Fri, 5 Feb 2021 02:56:05 +0000 (18:56 -0800)]
Fortinet: assume default route if no split routes received

That's what openfortivpn does, too: https://github.com/adrienverge/openfortivpn/blob/0fce4ba83260ce49b4d92b5eacae3acc3891ef91/src/ipv4.c#L1005-L1009

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: remove unused function
Daniel Lenski [Fri, 5 Feb 2021 02:55:04 +0000 (18:55 -0800)]
Fortinet: remove unused function

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: implement auth_expiration
Daniel Lenski [Fri, 5 Feb 2021 01:23:32 +0000 (17:23 -0800)]
Fortinet: implement auth_expiration

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: note divergences of header values from openfortivpn, and absence of DTLS...
Daniel Lenski [Fri, 5 Feb 2021 00:24:50 +0000 (16:24 -0800)]
Fortinet: note divergences of header values from openfortivpn, and absence of DTLS support

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: server rejects asyncmap and header compression options
Daniel Lenski [Thu, 4 Feb 2021 19:31:20 +0000 (11:31 -0800)]
Fortinet: server rejects asyncmap and header compression options

This appears to be a "feature" of all Fortinet servers, not just the one I have
access to. Openfortivpn calls pppd with the 'noaccomp nopfcomp default-asyncmap'
options: https://github.com/adrienverge/openfortivpn/blob/ba44ce1/src/tunnel.c#L233-L245

We should avoid offering these options to save an unnecessary round-trip in the
LCP stage of PPP configuration.

Don't blame me. I didn't design this.

For that matter, we don't need to include the asyncmap option with *any*
encapsulation that doesn't use HDLC.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet does not use HDLC framing
Daniel Lenski [Thu, 4 Feb 2021 20:38:49 +0000 (12:38 -0800)]
Fortinet does not use HDLC framing

It uses non-HDLC framing with a 6-byte header.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: socket switches abruptly from HTTP request to encapsulated PPP, with no...
Daniel Lenski [Thu, 4 Feb 2021 23:38:20 +0000 (15:38 -0800)]
Fortinet: socket switches abruptly from HTTP request to encapsulated PPP, with no HTTP-ish response

However, in the case of *failure* to start the PPP tunnel, an HTTP response
may be sent, and we'll need to detect that in the PPP mainloop.

Don't blame me. I didn't design this.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: explain to the user if connecting to an ancient server that doesn't support...
Daniel Lenski [Thu, 4 Feb 2021 01:58:00 +0000 (17:58 -0800)]
Fortinet: explain to the user if connecting to an ancient server that doesn't support XML config

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: ignore 401/403 response to remote/index request
Daniel Lenski [Wed, 3 Feb 2021 07:29:14 +0000 (23:29 -0800)]
Fortinet: ignore 401/403 response to remote/index request

Openfortivpn ignores the HTTP status code entirely in this request, and
others.  Testing shows that a 403 response here is routine and can be
ignored.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFortinet: set HTTP user-agent to 'Mozilla/5.0 SV1' as openfortivpn does
Daniel Lenski [Wed, 3 Feb 2021 06:57:52 +0000 (22:57 -0800)]
Fortinet: set HTTP user-agent to 'Mozilla/5.0 SV1' as openfortivpn does

This appears to suppress the need for 'host check' (presumably a
Trojan similar to those of other protocols) on some, if not all,
Fortinet servers.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoparse real Fortinet config
Daniel Lenski [Thu, 14 May 2020 03:41:00 +0000 (20:41 -0700)]
parse real Fortinet config

Based on these two real examples (https://forum.fortinet.com/tm.aspx?m=170415 and https://forum.fortinet.com/tm.aspx?m=105123).

Tested with sample XML in comments. Clean up a bunch of memory/state errors in PPP code (caught by static analyzer)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agohard-code browser UA into test-fortinet-login.py
Daniel Lenski [Sun, 17 May 2020 23:37:33 +0000 (16:37 -0700)]
hard-code browser UA into test-fortinet-login.py

See https://gitlab.com/openconnect/openconnect/-/issues/142#note_343854311

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd test-fortinet-login.py
Daniel Lenski [Wed, 13 May 2020 21:29:41 +0000 (14:29 -0700)]
add test-fortinet-login.py

Often easier to prototype HTTPS-based authentication flows in Python, since
they're so fiddly and arbitary.  So I copied `test-f5-login.py` to
`test-fortinet-login.py`.  Currently only handles basic
username-and-password auth, no 2FA:

```
usage: test-fortinet-login.py [-h] [-v] [-u USERNAME] [-p PASSWORD] [-r REALM]
                              [-c CERT] [--key KEY] [--no-verify]
                              endpoint [extra [extra ...]]

positional arguments:
  endpoint              Fortinet server (or complete URL, e.g.
                        https://forti.vpn.com/remote/login)
  extra                 Extra field to pass to include in the login query
                        string (e.g. "foo=bar")

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose
  --no-verify           Ignore invalid server certificate

Login credentials:
  -u USERNAME, --username USERNAME
                        Username (will prompt if unspecified)
  -p PASSWORD, --password PASSWORD
                        Password (will prompt if unspecified)
  -r REALM, --realm REALM
                        Realm (empty if unspecified)
  -c CERT, --cert CERT  PEM file containing client certificate (and optionally
                        private key)
  --key KEY             PEM file containing client private key (if not
                        included in same file as certificate)
```

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoAdd basic attempt at Fortinet support
David Woodhouse [Wed, 13 May 2020 13:58:56 +0000 (14:58 +0100)]
Add basic attempt at Fortinet support

Squashed Fortinet-specific code from 64eb98f068ceac0985d4356890c69b6a0bac0bdf..61edd9e6284aad30a5eb43ec84ff72171d46ca5f

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoF5: pause-and-reconnect doesn't preserve IP addresses if we PPP-terminate
Daniel Lenski [Mon, 8 Feb 2021 22:41:05 +0000 (14:41 -0800)]
F5: pause-and-reconnect doesn't preserve IP addresses if we PPP-terminate

Add a no_terminate_on_pause flag to handle this.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoF5: fix old options leak on reconnect
Daniel Lenski [Mon, 8 Feb 2021 21:38:40 +0000 (13:38 -0800)]
F5: fix old options leak on reconnect

Need to save in cstp_options, but also strdup() because
process_http_response() will clobber them if we don't

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoF5: one of the GET requests in login flow appears unnecessary
Daniel Lenski [Mon, 8 Feb 2021 21:28:28 +0000 (13:28 -0800)]
F5: one of the GET requests in login flow appears unnecessary

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoF5: implement f5_obtain_cookie
Daniel Lenski [Mon, 8 Feb 2021 20:43:07 +0000 (12:43 -0800)]
F5: implement f5_obtain_cookie

Like Fortinet, F5's authentication interface is very Javascript-heavy.
Unlike with Fortinet, I didn't even both to try to parse and "follow" HTML forms.

For now, we just create a static form (with username and password fields),
ask the user to fill it out, submit it, and attempt to detect successful login
by a length-0 response including F5_ST and MRHSession cookies.

The F5_ST cookie appears to be a reliable(?) indicator of successful login.
It's a "session timeout" cookie (https://support.f5.com/csp/article/K15387),
which looks like '1z1z1z1612808487z604800'. The 4th field appears to be the
Unix epoch timestamp of session activation, and the 5th appears to be the
duration in seconds until it expires.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd test-f5-login.py script
Daniel Lenski [Wed, 6 May 2020 20:01:28 +0000 (13:01 -0700)]
add test-f5-login.py script

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agouse check_address_sanity for F5 too
Daniel Lenski [Wed, 20 May 2020 01:45:51 +0000 (18:45 -0700)]
use check_address_sanity for F5 too

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFirst attempt at F5 support
David Woodhouse [Wed, 6 May 2020 11:26:45 +0000 (12:26 +0100)]
First attempt at F5 support

F5-specific code squashed from b072adc530ce74b1141e0a529d02fecb916c631c..08aa6af9e9bd93a71200631d38c84a6ac994a73e

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoppp-over-tls tests: fix PPP-over-IPv6 tests on Ubuntu
Daniel Lenski [Mon, 29 Mar 2021 02:55:18 +0000 (19:55 -0700)]
ppp-over-tls tests: fix PPP-over-IPv6 tests on Ubuntu

For reasons that are unclear, but probably also unimportant, IPv6 is disabled by default on this CI
image (verified in https://gitlab.com/openconnect/openconnect/-/jobs/1135199323#L335), and this will
cause PPP tests using IPv6 to fail.

Explicitly enabling IPv6 with sysctl resolves this.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoppp-over-tls tests: give up on CentOS 6
Daniel Lenski [Fri, 26 Feb 2021 02:39:45 +0000 (18:39 -0800)]
ppp-over-tls tests: give up on CentOS 6

We should be able to --enable-ppp-tests on CentOS 6, but they simply aren't working.

For reasons that are not clear, OpenConnect fails to handshake a TLS
connection to socat 1.7.2 (from CentOS 6 EPEL), and I don't want to install
an 11-year-old distribution on a VM just to figure out why.

So… no pppd-based tests for you, CentOS 6. 😡

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoppp-over-tls tests: more comments about how hard it is to use pppd as a test fixture
Daniel Lenski [Fri, 26 Feb 2021 01:53:38 +0000 (17:53 -0800)]
ppp-over-tls tests: more comments about how hard it is to use pppd as a test fixture

If anyone else ever has to touch this, they'll hopefully appreciate these.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoppp-over-tls tests: /etc/ppp script permissions problems
Daniel Lenski [Fri, 26 Feb 2021 01:53:38 +0000 (17:53 -0800)]
ppp-over-tls tests: /etc/ppp script permissions problems

Some CI is still failing because pppd can't successfully execute the
/etc/ppp/* scripts after configuring the interfaces. Let's just move these
out of the way so that pppd won't try to execute them.

Side rant: pppd is the most appallingly bad program in terms of separation
of concerns.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoppp-over-tls test: figured out how to make socat invoke pppd
Daniel Lenski [Fri, 26 Feb 2021 00:54:47 +0000 (16:54 -0800)]
ppp-over-tls test: figured out how to make socat invoke pppd

This should hopefully allow these tests to run without timing race
conditions on all CI platforms.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoppp-over-tls tests: try to keep CentOS 6 CI working, and improve flaky startup of...
Daniel Lenski [Wed, 24 Feb 2021 05:03:47 +0000 (21:03 -0800)]
ppp-over-tls tests: try to keep CentOS 6 CI working, and improve flaky startup of pppd

Even with EPEL, CentOS has an old version of socat which doesn't support the
'rawer' option, so let's use the older 'raw,echo=0' combination to keep it
limping along.

More carefully try to verify that socat and pppd start up and connect to each other:

- Wait for socat to create PTY in 1-second increments, and keep going until PTY
  actually exists (up to 15 seconds).
- Wait for ppp to connect to PTY in 1-second increments, and keep going until pppd
  creates a "UUCP-style lockfile" for the PTY.
- Log how long it takes for the above process to complete (socat and pppd combined
  startup) in the test output.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoppp: add comment about likely meaninglessness of server's LL IPv6 address
Daniel Lenski [Wed, 24 Feb 2021 04:51:12 +0000 (20:51 -0800)]
ppp: add comment about likely meaninglessness of server's LL IPv6 address

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoautomatically disable pppd tests if socat or pppd are missing
Daniel Lenski [Mon, 22 Feb 2021 07:14:00 +0000 (23:14 -0800)]
automatically disable pppd tests if socat or pppd are missing

This way, we can also automatically ENABLE them as soon as they're built into CI images.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agounset delay_tunnel_reason as soon as PPP reaches network state
Daniel Lenski [Wed, 10 Feb 2021 07:10:57 +0000 (23:10 -0800)]
unset delay_tunnel_reason as soon as PPP reaches network state

This prevents an unnecessary extra iteration of waiting for PPP negotiation.
Caught via ppp-over-tls test logs.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoclarify un-HDLC logging a bit
Daniel Lenski [Wed, 10 Feb 2021 07:09:31 +0000 (23:09 -0800)]
clarify un-HDLC logging a bit

Leftover bytes due to concatenated packet shouldn't be reported as part of
the un-HDLC size reduction.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix nakbuf leak
Daniel Lenski [Tue, 9 Feb 2021 19:34:13 +0000 (11:34 -0800)]
fix nakbuf leak

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoCI: re-enable PPP tests for CentOS7, Fedora, and Ubuntu
Daniel Lenski [Tue, 9 Feb 2021 00:08:17 +0000 (16:08 -0800)]
CI: re-enable PPP tests for CentOS7, Fedora, and Ubuntu

Still to-do:
1) Get socat+pppd working in CentOS8 and CentOS6 CI
2) Figure out why PPP tests are so slow (added log retention for 1 week, even on success, in Ubuntu18.04/GnuTLS build)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agogive nullppp the option of cancelling/terminating itself after negotation
Daniel Lenski [Tue, 9 Feb 2021 03:26:00 +0000 (19:26 -0800)]
give nullppp the option of cancelling/terminating itself after negotation

With 'term' in the cookie, nullppp will initiate a clean termination after successful
PPP negiation.

This is a much cleaner way to run tests than starting OpenConnect in the background,
sleeping, and killing.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoimprove ppp-over-tls tests
Daniel Lenski [Tue, 9 Feb 2021 01:07:10 +0000 (17:07 -0800)]
improve ppp-over-tls tests

- Cleanup ugly pppd syntax
- Always set 'nodefaultroute' and negotiate link-local IPv4 addresses
- Don't rely on non-root to cause OpenConnect to terminate
- More tests with HDLC, only one without

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agomore accurate PPP-over-TLS MTU calculation
Daniel Lenski [Mon, 8 Feb 2021 10:08:59 +0000 (02:08 -0800)]
more accurate PPP-over-TLS MTU calculation

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFix three sanitizer complaints
Daniel Lenski [Mon, 8 Feb 2021 08:31:36 +0000 (00:31 -0800)]
Fix three sanitizer complaints

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd ppp-over-tls tests (with pppd as the reference peer implementation)
Daniel Lenski [Fri, 22 May 2020 03:47:59 +0000 (20:47 -0700)]
add ppp-over-tls tests (with pppd as the reference peer implementation)

These test OpenConnect's ability to communicate with the standard pppd using
PPP-over-TLS, with a variety of PPP negotiation options:

  ± IPv4
  ± IPv6
  ± DNS and NBNS server negotiation
  ± PPP header protocol/address field compression
  ± Van Jacobson header compression (always rejected by OpenConnect)

These tests use socat to create TLS socket pairs, connecting `openconnect
--protocol=nullppp` to one end and `pppd` to the other.

I tried and failed to combine socat and pppd invocations, but pppd seemingly
cannot handle being wrapped by libsocket_wrapper.so (nor libuid_wrapper.so;
it must run as root).

`pppd sync` (non-HDLC framing) appears to have trouble reacting to incoming
packets in this configuration, so OpenConnect has to invoke retry timers during
negotiation. This seems to be a bug in pppd, rather than a flaw in OpenConnect's
implementation of PPP. Added logging of the time that each run takes.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd OC_PROTO_HIDDEN and use this to hide nullppp from protocols displayed or shown...
Daniel Lenski [Wed, 20 May 2020 03:53:25 +0000 (20:53 -0700)]
add OC_PROTO_HIDDEN and use this to hide nullppp from protocols displayed or shown by openconnect_get_supported_protocols

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd 'nullppp' protocol for testing
Daniel Lenski [Tue, 19 May 2020 21:36:48 +0000 (14:36 -0700)]
add 'nullppp' protocol for testing

Use `socat` to set up a PTY connected to a TLS socket (listening only on the local interface):

    socat -s -d -d \
      PTY,raw,b9600 \
      OPENSSL-LISTEN:5556,cert=tests/certs/server-cert.pem,key=tests/certs/server-key.pem,verify=0,so-bindtodevice=lo
    [ N PTY is /dev/pts/X ]

Connect the PTY to `pppd` (requires root):

    # Add 'sync' to disable HDLC framing
    sudo pppd /dev/pts/X 10.0.0.1:10.0.0.101 noauth debug dump logfd 2 local nodetach passive persist ms-dns 1.1.1.1 ms-wins 5.5.5.5 +ipv6

Connect OpenConnect to the TLS socket, and watch it negotiate LCP/IPCP/IP6CP with its peer, and reject CCP:

    # Add noipv4,noipv6 to cookie to try those
    ./openconnect --protocol=nullppp --cookie hdlc --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --dump localhost:5556

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd support for PPP-based protocols
David Woodhouse [Wed, 6 May 2020 21:10:42 +0000 (22:10 +0100)]
add support for PPP-based protocols

This started out as the 'f5' branch, which was then rebased (by DL) onto a
more recent master as 'ppp_rebased'.

This was then squashed down into a single commit, with all of the bits
depending on "real" PPP-based VPN protocols removed, so that only the shell
of generic PPP support remains, including PPP protocol negotation (LCP,
IPCP, IP6CP) and mainloop.

Almost all of this code was done by David Woodhouse and Daniel Lenski in
May 2020, with a few more recent bugfixes by DL in early February 2021.

The remaining shell supports two different encapsulations of PPP:

    - PPP_ENCAP_RFC1661: Plain PPP. “Synchronous” in the ’90s-era language,
      because the start and end of the frame are known from external means.

      In modern instances, this is because they arrive in a complete packet with
      a known length from its lower-level encapsulation. (TLS or DTLS records in
      our expected use cases.)

      This is what `pppd sync` does.

    - PPP_ENCAP_RFC1662: “PPP in HDLC-like framing.”

      This is what `pppd` without `sync` does.

The following commits will add tests to demonstrate the functionality of
OpenConnect's PPP implementation at the level of this generic encapsulation.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoJuniper: bugfix handling of loginForm.VerificationCode
Daniel Lenski [Mon, 29 Mar 2021 02:00:52 +0000 (19:00 -0700)]
Juniper: bugfix handling of loginForm.VerificationCode

Need to whitelist this form by 'auth_id' in oncp_can_gen_tokencode. Missed in f582b233afc688cd7090aa01ee1a0af61597bef1.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix <select>/<option> parsing bug
Daniel Lenski [Tue, 23 Feb 2021 04:46:15 +0000 (20:46 -0800)]
fix <select>/<option> parsing bug

The Juniper form-handling code was setting <select>/<option> labels
identically to their values.

Presumably, this was never caught before because they never actually differ
in real Juniper login forms? (but they do in F5 forms)

That is, a Juniper <option> field always looks like…

    <select name="realm">
      <option value="Something">Something</option>
      <option value="Another">Another</option>
    </select>

… and never like this:

    <select name="realm">
      <option value="group1">Something</option>
      <option value="group2">Another</option>
    </select>

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd openconnect__strchrnul function to compat.c
Daniel Lenski [Sat, 20 Feb 2021 17:39:07 +0000 (09:39 -0800)]
add openconnect__strchrnul function to compat.c

GNU strchrnul() is trivial to implement, and makes a bunch of string parsing
functions simpler and less error-prone.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoallegedly universal MTU calculator: use for GPST and PPP
Daniel Lenski [Sat, 16 May 2020 22:51:46 +0000 (15:51 -0700)]
allegedly universal MTU calculator: use for GPST and PPP

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofactor out internal_split_cookies from auth-juniper.c
Daniel Lenski [Mon, 8 Feb 2021 19:38:19 +0000 (11:38 -0800)]
factor out internal_split_cookies from auth-juniper.c

This is useful for other protocols that use HTTP cookies for authentication, and may
need a way to handoff >1 cookie from the authentication phase to the connection phase.

Improve it slightly by allowing it to set a "default" HTTP cookie if the
authcookie string doesn't contain '=', since most protocols really only NEED
one cookie for the connection phase to work.

This allows shortcuts (like `openconnect --protocol=nc -C 'foobar'` → 'Cookie: DSID=foobar'
or `openconnect --protocol=fortinet -C 'ABCD123456=='` → 'Cookie: SVPNCOOKIE=ABCD123456==') without limiting
the ability to store multiple cookies if/when useful.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agosplit htmlnode_next and htmlnode_dive
Daniel Lenski [Mon, 8 Feb 2021 01:47:08 +0000 (17:47 -0800)]
split htmlnode_next and htmlnode_dive

htmlnode_next(): try ->next, before ->parent
htmlnode_dive(): try children, before ->next, before ->parent

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofactor out internal_get_url function
Daniel Lenski [Sun, 7 Feb 2021 22:20:06 +0000 (14:20 -0800)]
factor out internal_get_url function

Returns 'https://hostname[:port][/urlpath]' in a newly malloc'ed string.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoauth-juniper.c simplifications (including ignoring submit_button if NULL)
Daniel Lenski [Sun, 7 Feb 2021 21:50:12 +0000 (13:50 -0800)]
auth-juniper.c simplifications (including ignoring submit_button if NULL)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agooncp_control_queue → tcp_control_queue
Daniel Lenski [Mon, 11 May 2020 22:34:34 +0000 (15:34 -0700)]
oncp_control_queue → tcp_control_queue

This is a queue for outgoing packets which must be sent over the
TCP-based transport; that is, they cannot be sent over the
UDP-based transport.

This queue was initially used by oNCP protocol for ESP enable/disable
packets, and it is now also used by Pulse. It will likely be used for
control packets by some PPP-based protocols as well.

Renaming it to TCP control queue to emphasize its cross-protocol
nature (cf. https://gitlab.com/openconnect/openconnect/-/merge_requests/151).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agomake buf_append_{be16,be32,le16} global
Daniel Lenski [Fri, 8 May 2020 07:11:51 +0000 (00:11 -0700)]
make buf_append_{be16,be32,le16} global

These functions are already used by both oNCP and Pulse protocols,
and will be used by PPP protocols as well. Make them shared/global.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFix printf types in stats output
David Woodhouse [Sat, 27 Mar 2021 15:01:58 +0000 (15:01 +0000)]
Fix printf types in stats output

More build warnings, not even just on Windows this time.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoCast GetVolumeInformationByHandleW to (void *)
David Woodhouse [Sat, 27 Mar 2021 15:00:34 +0000 (15:00 +0000)]
Cast GetVolumeInformationByHandleW to (void *)

The 64-bit Windows build was complaining of pointer type mismatches but
I'm fairly sure it was a false positive:

../ssl.c: In function 'openconnect_passphrase_from_fsid':
../ssl.c:598:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, WCHAR *, DWORD,  DWORD *, DWORD *, DWORD *, WCHAR *, DWORD)' {aka 'int (*)(void *, short unsigned int *, long unsigned int,  long unsigned int *, long unsigned int *, long unsigned int *, short unsigned int *, long unsigned int)'} [-Wcast-function-type]
  598 |  func = (GVIBH)GetProcAddress(kernlib, "GetVolumeInformationByHandleW");
      |         ^

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoResync translations with sources
David Woodhouse [Sat, 27 Mar 2021 10:36:35 +0000 (10:36 +0000)]
Resync translations with sources

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoUpdate translations from GNOME
David Woodhouse [Sat, 27 Mar 2021 10:36:18 +0000 (10:36 +0000)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix non-Windows compilation. I hate autoconf.
David Woodhouse [Sat, 27 Mar 2021 10:31:55 +0000 (10:31 +0000)]
Fix non-Windows compilation. I hate autoconf.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'no_more_X-AnyConnect-Platform_header' of gitlab.com:openconnect/openconnect
David Woodhouse [Sat, 27 Mar 2021 10:06:06 +0000 (10:06 +0000)]
Merge branch 'no_more_X-AnyConnect-Platform_header' of gitlab.com:openconnect/openconnect

4 years agoFix Windows build warning: No %zd for size_t on Windows
David Woodhouse [Sat, 27 Mar 2021 09:44:18 +0000 (09:44 +0000)]
Fix Windows build warning: No %zd for size_t on Windows

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix Win32 build warnings about _putenv_s() redeclaration
David Woodhouse [Sat, 27 Mar 2021 09:36:41 +0000 (09:36 +0000)]
Fix Win32 build warnings about _putenv_s() redeclaration

../compat.c:30:9: error: '_putenv_s' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
   30 | errno_t _putenv_s(
      |         ^~~~~~~~~

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'handle_GP_cookie_rejected_errors' of gitlab.com:openconnect/openconnect
David Woodhouse [Sat, 27 Mar 2021 10:04:03 +0000 (10:04 +0000)]
Merge branch 'handle_GP_cookie_rejected_errors' of gitlab.com:openconnect/openconnect

4 years agoadd link to online documentation, put TAP-Windows in named section, and… changelog
Daniel Lenski [Fri, 26 Mar 2021 18:49:38 +0000 (11:49 -0700)]
add link to online documentation, put TAP-Windows in named section, and… changelog

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoCI: update artifact paths for MinGW* builds
Daniel Lenski [Fri, 26 Mar 2021 17:56:23 +0000 (10:56 -0700)]
CI: update artifact paths for MinGW* builds

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'master' into build_NSIS_based_installers_for_32bit_Windows
Daniel Lenski [Fri, 26 Mar 2021 17:50:19 +0000 (10:50 -0700)]
Merge branch 'master' into build_NSIS_based_installers_for_32bit_Windows

4 years agoremove now-unneeded make-windows-installer.sh, re-embed vpnc-script-win.js, embed...
Daniel Lenski [Fri, 26 Mar 2021 16:48:38 +0000 (09:48 -0700)]
remove now-unneeded make-windows-installer.sh, re-embed vpnc-script-win.js, embed OpenVPN TAP-Windows installer

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoset OCCTL_SOCKET in tests/common.sh, if unset
Daniel Lenski [Fri, 26 Mar 2021 17:46:08 +0000 (10:46 -0700)]
set OCCTL_SOCKET in tests/common.sh, if unset

This way, individual test scripts don't need to all set it identically.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix pfs and obsolete-server-crypto tests on Ubuntu
Daniel Lenski [Fri, 26 Mar 2021 17:33:40 +0000 (10:33 -0700)]
fix pfs and obsolete-server-crypto tests on Ubuntu

These broke in 32e97b4cfa6ae140a25f7ab3e56f9d61e400b50e, due to the removal of the default ocserv socket-file

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoActually create installer packages for MinGW builds
David Woodhouse [Fri, 26 Mar 2021 16:55:09 +0000 (16:55 +0000)]
Actually create installer packages for MinGW builds

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix up NSIS ProductVersion for RPM version strings
David Woodhouse [Fri, 26 Mar 2021 16:29:54 +0000 (16:29 +0000)]
Fix up NSIS ProductVersion for RPM version strings

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix obsolete-server-crypto in the GnuTLS build not the OpenSSL one.
David Woodhouse [Fri, 26 Mar 2021 15:54:39 +0000 (15:54 +0000)]
Fix obsolete-server-crypto in the GnuTLS build not the OpenSSL one.

We're clearing OpenSSL capabilities in the GnuTLS tests to work around
a SoftHSM bug, which is what confused me into putting the XFAIL in the
wrong case.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'master' into build_NSIS_based_installers_for_32bit_Windows
Daniel Lenski [Fri, 26 Mar 2021 15:52:48 +0000 (08:52 -0700)]
Merge branch 'master' into build_NSIS_based_installers_for_32bit_Windows

4 years agoAdd makensis to mingw COPR builds
David Woodhouse [Fri, 26 Mar 2021 15:43:26 +0000 (15:43 +0000)]
Add makensis to mingw COPR builds

Let's see if we can make it spit out an installer each time...

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoAdd obsolete-server-crypto to XFAIL tests in Fedora package
David Woodhouse [Fri, 26 Mar 2021 15:38:16 +0000 (15:38 +0000)]
Add obsolete-server-crypto to XFAIL tests in Fedora package

The Fedora specfile explicitly sets the GnuTLS priority string to
include @OPENCONNECT but the test sets GNUTLS_SYSTEM_PRIORITY_FILE
to point to /dev/null so that stops working. Just XFAIL the test for
now so the builds start working again. More thinking required...

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix up string handling for ciphersuite_config
David Woodhouse [Fri, 26 Mar 2021 15:34:17 +0000 (15:34 +0000)]
Fix up string handling for ciphersuite_config

Sure it isn't C++ and std::string, but we *have* a method for appending
strings to a dynamic buffer. We don't need this snprintf("%s%s%s%s%s")
nonsense.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix pfs test for out-of-tree builds
David Woodhouse [Fri, 26 Mar 2021 14:52:40 +0000 (14:52 +0000)]
Fix pfs test for out-of-tree builds

Originally we generated config files from autoconf, so we had:
 • ${srcdir}/tests/configs/test-foo.in
 • ${builddir}/tests/configs/test-foo

Later, we wanted to generate files more dynamically at runtime with
different contents, so we added the update_config() function in
tests/common.sh which did its own substitution to a temporary file,
from
 • $(srcdir}/tests/configs/test-foo

The pfs and obsolete-server-crypto tests appear to use a broken hybrid
of the two, first creating ${builddir}/tests/configs/test-foo from
autoconf and then attempting to use ${srcdir}/tests/configs/test-foo
at runtime. The latter isn't going to exist if ${srcdir} != ${builddir}.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoDrop web page handling
David Woodhouse [Fri, 26 Mar 2021 14:03:10 +0000 (14:03 +0000)]
Drop web page handling

The web site is handled by a cron job; if we wanted to flip that
over to pull from gitlab instead of git.infradead.org it would
be simple enough to it. Let's keep it in the same place for now.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoAdd basic NSIS installer
David Woodhouse [Fri, 26 Mar 2021 10:24:25 +0000 (10:24 +0000)]
Add basic NSIS installer

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoremove unneeded inc/* and openconnect.8.inc from public/HTML docs
Daniel Lenski [Fri, 26 Mar 2021 00:20:34 +0000 (17:20 -0700)]
remove unneeded inc/* and openconnect.8.inc from public/HTML docs

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agocreate make-windows-installer.sh
Daniel Lenski [Fri, 26 Mar 2021 00:20:05 +0000 (17:20 -0700)]
create make-windows-installer.sh

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoremove unneeded inc/* and openconnect.8.inc from public/HTML docs
Daniel Lenski [Fri, 26 Mar 2021 00:20:34 +0000 (17:20 -0700)]
remove unneeded inc/* and openconnect.8.inc from public/HTML docs

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd note about existence of installers in packaging docs
Daniel Lenski [Thu, 25 Mar 2021 20:05:20 +0000 (13:05 -0700)]
add note about existence of installers in packaging docs

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoinclude vpnc-script-win.js in installer
Daniel Lenski [Thu, 25 Mar 2021 20:01:22 +0000 (13:01 -0700)]
include vpnc-script-win.js in installer

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoNSIS installer: add compression, installer file properties, and docs
Daniel Lenski [Thu, 25 Mar 2021 18:31:16 +0000 (11:31 -0700)]
NSIS installer: add compression, installer file properties, and docs

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMingW32 builds: generate NSIS installers for Windows
Daniel Lenski [Tue, 23 Mar 2021 17:55:19 +0000 (10:55 -0700)]
MingW32 builds: generate NSIS installers for Windows

nsiswrapper is a rather dodgy Perl script (looks like it hasn't actually
been updated since ~2009) with one indispensable function: it can
automatically find required DLLs and bundle them into the installer.

1. The `PATH` variable must be set to include DLL locations (why `PATH`?️)
2. It mixes up its stdout and stderr, so `--verbose` can't be used without
   `--run`. (Argh…)
3. It doesn't try to normalize the paths of the bundled files, so
   `./x` and `$PWD/x` result in different directory structures.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'jkuebart:fix/forms-without-action'
Daniel Lenski [Wed, 24 Mar 2021 18:59:35 +0000 (11:59 -0700)]
Merge branch 'jkuebart:fix/forms-without-action'

See merge request openconnect/openconnect\!171

4 years agoadd changelog entry
Daniel Lenski [Wed, 24 Mar 2021 18:56:59 +0000 (11:56 -0700)]
add changelog entry

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd changelog entry
Daniel Lenski [Tue, 16 Mar 2021 21:47:39 +0000 (14:47 -0700)]
add changelog entry

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agocstp: don't send X-AnyConnect-Platform header
Daniel Lenski [Tue, 16 Mar 2021 21:40:18 +0000 (14:40 -0700)]
cstp: don't send X-AnyConnect-Platform header

1. Cisco AnyConnect 4.8+ no longer sends it, and some newer servers reject
   any client which sends it (see #101)… including older versions of Cisco's
   own client. (Great job, Cisco 🤦🏻‍♂️.)
2. We can't find any evidence of older Cisco servers which *do* require this
   header to be present in order to authenticate the client.
3. It's redundant. Any server that wants to know the client's platform as
   soon as it receives the initial XML POST already has it. (It's in the
   <device-id> tag in addition to the header.)

If there actually are any servers that *do* require this header to identify
and authenticate the client/platform, then the `--local-id` mechanism of
!103 is probably the right way to ensure that it is sent.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'fix/tncc-exception' into 'master'
Daniel Lenski [Mon, 15 Mar 2021 17:31:51 +0000 (17:31 +0000)]
Merge branch 'fix/tncc-exception' into 'master'

fix: don't raise when TNCC_CERTS is unset

See merge request openconnect/openconnect!173

4 years agofix: don't raise when TNCC_CERTS is unset
Joachim Kuebart [Mon, 8 Mar 2021 15:58:35 +0000 (16:58 +0100)]
fix: don't raise when TNCC_CERTS is unset

When asn1crypto isn't available, only raise if TNCC_CERTS is set. That's
the semantics suggested by the error message.

Signed-off-by: Joachim Kuebart <joachim.kuebart@gmail.com>
4 years agonit: silence deprecation warning
Joachim Kuebart [Mon, 8 Mar 2021 15:33:21 +0000 (16:33 +0100)]
nit: silence deprecation warning

Using logging.warn() causes a deprecation warning. Even Python 2.7 appears
to have logging.warning(), so use that instead.

Signed-off-by: Joachim Kuebart <joachim.kuebart@gmail.com>