]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
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 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>
4 years agofeat: support Microsoft SSO
Joachim Kuebart [Tue, 9 Mar 2021 14:26:30 +0000 (15:26 +0100)]
feat: support Microsoft SSO

Signed-off-by: Joachim Kuebart <joachim.kuebart@gmail.com>
4 years agofix: keep going when forms have only hidden fields
Joachim Kuebart [Tue, 9 Mar 2021 12:48:19 +0000 (13:48 +0100)]
fix: keep going when forms have only hidden fields

Don't consider forms with hidden fields empty.

Signed-off-by: Joachim Kuebart <joachim.kuebart@gmail.com>
4 years agofix: support forms without "action"
Joachim Kuebart [Tue, 9 Mar 2021 12:45:35 +0000 (13:45 +0100)]
fix: support forms without "action"

The HTML spec states:
    If action is the empty string, let action be the URL of the form
    document.
    https://html.spec.whatwg.org/#concept-form-submit

This occurs for me in a scenario using Azure SSO.

Signed-off-by: Joachim Kuebart <joachim.kuebart@gmail.com>
4 years agoMerge branch 'fix/field-instead-of-global' into 'master'
Daniel Lenski [Tue, 9 Mar 2021 22:42:40 +0000 (22:42 +0000)]
Merge branch 'fix/field-instead-of-global' into 'master'

fix: use field instead of global variable

See merge request openconnect/openconnect!172

4 years agofix: use field instead of global variable
Joachim Kuebart [Tue, 9 Mar 2021 14:25:45 +0000 (15:25 +0100)]
fix: use field instead of global variable

The TNCC "emulate" trojan erroneously uses a global variable instead of a
field.

Signed-off-by: Joachim Kuebart <joachim.kuebart@gmail.com>
4 years agobugfix: condition for incomplete ESP config with GP was inverted
Daniel Lenski [Sun, 7 Mar 2021 22:40:00 +0000 (14:40 -0800)]
bugfix: condition for incomplete ESP config with GP was inverted

Fixes #227. Messed this up in https://gitlab.com/openconnect/openconnect/-/commit/edb1591f313167df4b708123e338975335b55203

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'add_DTLS_disable_to_API' into 'master'
Daniel Lenski [Thu, 25 Feb 2021 18:32:59 +0000 (18:32 +0000)]
Merge branch 'add_DTLS_disable_to_API' into 'master'

add openconnect_disable_dtls() API function

See merge request openconnect/openconnect!49

4 years agoMerge branch 'potential_read_overflow_in_openconnect__strndup' into 'master'
Daniel Lenski [Thu, 25 Feb 2021 17:07:40 +0000 (17:07 +0000)]
Merge branch 'potential_read_overflow_in_openconnect__strndup' into 'master'

fix potential read overflow in openconnect__strndup

See merge request openconnect/openconnect!170

4 years agoadd .gitattributes file to mark binaries
Daniel Lenski [Wed, 24 Feb 2021 02:41:03 +0000 (18:41 -0800)]
add .gitattributes file to mark binaries

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix potential read overflow in compat.c replacement for strndup()
Daniel Lenski [Tue, 23 Feb 2021 05:17:13 +0000 (21:17 -0800)]
fix potential read overflow in compat.c replacement for strndup()

The openconnect__strndup() function is used as a replacement for
strndup() on platforms that lack it.

It is unsafe in its current form, because it calls strlen() on
a buffer that may not be zero-terminated.

Here's a short C program that demonstrates the issue:

    #include <stdio.h>
    #include <string.h>

    int main(int argc, char **argv)
    {
        char *foo = (void *)printf; /* should be legal to read at least 4 bytes */
        printf("We didn't crash in strndup (EXPECTED): %s.\n", strndup(foo, 3));
        printf("We didn't crash in strlen (NOT GUARANTEED): %d\n", strlen(foo));
        return 0;
    }

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoensure that openconnect_disable_{dtls,ipv6} do nothing if vpninfo has ever been connected
Daniel Lenski [Thu, 13 Jun 2019 15:53:27 +0000 (10:53 -0500)]
ensure that openconnect_disable_{dtls,ipv6} do nothing if vpninfo has ever been connected

Both openconnect_disable_dtls() and openconnect_disable_ipv6() now return
int (0 or -EINVAL), and are used in CLI argument processing.

Ideally, we would allow these to be used when IPv6 or DTLS/ESP are not currently
in use, but we do not have sufficiently reliable cross-protocol indicators of these.
The main use case for both of these functions is disable a problematic feature
prior to initial connection.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd openconnect_disable_dtls() API function
Daniel Lenski [Wed, 5 Jun 2019 03:30:30 +0000 (20:30 -0700)]
add openconnect_disable_dtls() API function

This also adds the API function to the Java bindings.

The immediate motivation is that there are a lot of Android users with
MTU-related issues (https://github.com/cernekee/ics-openconnect), and
disabling UDP/DTLS/ESP is a good temporary band-aid.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agostatic website tweaks
Daniel Lenski [Sat, 20 Feb 2021 01:11:25 +0000 (17:11 -0800)]
static website tweaks

We don't need the artifacts from any builds, and add a dedicated Makefile target to update the '/public' directory.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoTry to generate static website using GitLab pages
Daniel Lenski [Sat, 20 Feb 2021 00:05:09 +0000 (00:05 +0000)]
Try to generate static website using GitLab pages

Based on the example at https://gitlab.com/pages/plain-html, and ocserv's configuration (https://gitlab.com/openconnect/ocserv/blob/master/.gitlab-ci.yml)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agochangelog: more updates since v8.10
Daniel Lenski [Thu, 18 Feb 2021 16:15:59 +0000 (08:15 -0800)]
changelog: more updates since v8.10

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'remove_protocol_specific_values_from_global_state_object' into 'master'
Daniel Lenski [Thu, 11 Feb 2021 17:20:53 +0000 (17:20 +0000)]
Merge branch 'remove_protocol_specific_values_from_global_state_object' into 'master'

CSD XML tag and nostub are entirely protocol-specific and used in only one place

See merge request openconnect/openconnect!159

4 years agoadd pointer to vpnc-script repo to README
Daniel Lenski [Thu, 11 Feb 2021 17:11:05 +0000 (09:11 -0800)]
add pointer to vpnc-script repo to README

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'allow_multiple_servercert_arguments' into 'master'
Daniel Lenski [Fri, 5 Feb 2021 17:31:05 +0000 (17:31 +0000)]
Merge branch 'allow_multiple_servercert_arguments' into 'master'

Allow specification of multiple certificate fingerprints on command-line via --servercert

See merge request openconnect/openconnect!162

4 years agochangelog
Daniel Lenski [Mon, 25 Jan 2021 08:04:15 +0000 (00:04 -0800)]
changelog

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoallow specification of multiple certificate fingerprints on command-line via --servercert
Daniel Lenski [Mon, 25 Jan 2021 07:39:39 +0000 (23:39 -0800)]
allow specification of multiple certificate fingerprints on command-line via --servercert

Server certificates will be accepted if they match *any* of the provided fingerprints.

Behavior with `--servercert` is otherwise unchanged; it still disables system trust
stores, meaning that _only_ certificates matching the provided fingerprints will be
accepted if it is specified one or more times.

This will allow the use of `--servercert` to non-interactively connect to a server which
has a non-trusted certificate and redirects to one or more other servers with non-trusted
certificates. (See #25 for a real case.)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'one_more_pulse_failcode' into 'master'
Daniel Lenski [Wed, 3 Feb 2021 21:34:40 +0000 (21:34 +0000)]
Merge branch 'one_more_pulse_failcode' into 'master'

Pulse: one more known failcode (0x0e = client cert required)

See merge request openconnect/openconnect!163

4 years agoJuniper forms with 'id' but not 'name'
Daniel Lenski [Mon, 1 Feb 2021 18:52:17 +0000 (10:52 -0800)]
Juniper forms with 'id' but not 'name'

Speculative fix for #219

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoPulse: one more known failcode (0x0e = client cert required)
Daniel Lenski [Tue, 15 Dec 2020 18:02:21 +0000 (10:02 -0800)]
Pulse: one more known failcode (0x0e = client cert required)

Verified by connecting to a Pulse server which requires a client cert,
without providing one via -c/-k.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'openssl-sec-level' into 'master'
Daniel Lenski [Sat, 23 Jan 2021 01:07:07 +0000 (01:07 +0000)]
Merge branch 'openssl-sec-level' into 'master'

With --allow-insecure-crypto, set OpenSSL 1.1.0+ "security level" to 0, and attempt to disable system minimum crypto requirements

See merge request openconnect/openconnect!158

4 years agoupdate changelog with expanded scope
Daniel Lenski [Sat, 23 Jan 2021 01:02:00 +0000 (17:02 -0800)]
update changelog with expanded scope

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoin tests/obsolete-server-crypto, do not override GNUTLS_SYSTEM_PRIORITY_FILE when...
Daniel Lenski [Sat, 23 Jan 2021 00:47:35 +0000 (16:47 -0800)]
in tests/obsolete-server-crypto, do not override GNUTLS_SYSTEM_PRIORITY_FILE when invoking OpenConnect

This will allow us to test OpenConnect's ability to disable the system-wide crypto policy by itself.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agowith --allow-insecure-crypto, additionally attempt to disable insecure systemwide...
Daniel Lenski [Fri, 22 Jan 2021 00:27:23 +0000 (16:27 -0800)]
with --allow-insecure-crypto, additionally attempt to disable insecure systemwide minimum crypto settings

Because openconnect_set_allow_insecure_crypto() now does more than just attempt to reenable 3DES and ARC4,
its failure to enable those ciphers should not be treated as fatal, but merely a warning.

Setting the appropriate environment variable (GNUTLS_SYSTEM_PRIORITY_FILE or OPENSSL_CONF) to `/dev/null`
*before* crypto library initialization should ensure that a systemwide crypto configuration file doesn't
set a minimum crypto requirement which would override the user choice.

See https://gitlab.com/openconnect/openconnect/-/issues/211#note_482161646 for discussion of GnuTLS
settings, and https://www.openssl.org/docs/man1.1.1/man5/config.html for OpenSSL.

FIXME: OpenSSL implementation needs library reinitialization.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd openconnect__win32_setenv function to compat.c
Daniel Lenski [Fri, 22 Jan 2021 02:01:42 +0000 (18:01 -0800)]
add openconnect__win32_setenv function to compat.c

Based on:

* POSIX-compatible `setenv` implementation for Windows: https://stackoverflow.com/a/23616164
* Enabling Windows "secure API" getenv_s and _putenv_s functions in MinGW:
  * Using -DMINGW_HAS_SECURE_API: https://stackoverflow.com/a/51977723
  * By manually defining their prototypes: https://stackoverflow.com/a/51977723
  * Apparently, only newer versions of MinGW follow the MINGW_HAS_SECURE_API flag, and
    autodetecting them is quite hard.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoonly set OpenSSL security level to 0 when --allow-insecure-crypto is specified
Daniel Lenski [Fri, 22 Jan 2021 00:21:01 +0000 (16:21 -0800)]
only set OpenSSL security level to 0 when --allow-insecure-crypto is specified

See discussions on https://gitlab.com/openconnect/openconnect/-/issues/211 for rationale.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'clobbered-loop-counter-bug' into 'master'
Daniel Lenski [Wed, 20 Jan 2021 23:24:02 +0000 (23:24 +0000)]
Merge branch 'clobbered-loop-counter-bug' into 'master'

Use separate counters for inner and outer loop.

See merge request openconnect/openconnect!161

4 years agoUse separate counters for inner and outer loop.
Tom Carroll [Sat, 16 Jan 2021 07:37:42 +0000 (23:37 -0800)]
Use separate counters for inner and outer loop.

The inner and outer loop share a counter. The inner loop resets the
counter to zero when entering the loop. I don't believe this is the
intention from an examination of the code. Have inner and outer loops
use separate counters.

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
4 years agoMerge branch 'assign_privkey-bug' into 'master'
Daniel Lenski [Fri, 8 Jan 2021 23:58:15 +0000 (23:58 +0000)]
Merge branch 'assign_privkey-bug' into 'master'

Small memory leak in gnutls.c:assign_privkey

See merge request openconnect/openconnect!160

4 years agoFree pcerts array for all assign_privkey paths.
Tom Carroll [Fri, 8 Jan 2021 19:26:48 +0000 (11:26 -0800)]
Free pcerts array for all assign_privkey paths.

Ensure the array pcerts is free'd for both success/fail paths. The function
gnutls_certificate_set_key() is odd as it takes ownership of the contents of
pcerts, but not the pcerts array itself. See:

gnutls-3.6.15/lib/cert-cred.c:gnutls_certificate_set_key()
...
new_pcert_list = gnutls_malloc(sizeof(gnutls_pcert_st) * pcert_list_size);
if (new_pcert_list == NULL) {
  return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
}
memcpy(new_pcert_list, pcert_list, sizeof(gnutls_pcert_st) * pcert_list_size);

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
4 years agoAlways set security level to 0 for openssl versions >= 1.1.0
Elias Norberg [Fri, 1 May 2020 12:08:02 +0000 (14:08 +0200)]
Always set security level to 0 for openssl versions >= 1.1.0

In version 1.1.0 of OpenSSL, a security level was introduced that enforces specific settings for certificates etc.
This PR sets the security level to 0, to retain the functionality that
previous versions of openssl had, and preventing errors like:

140088222534656:error:140AB18E:SSL routines:SSL_CTX_use_certificate:ca md too weak:../ssl/ssl_rsa.c:310

See https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_security_level.html for more information about security levels.

Signed-off-by: Elias Norberg <elias@aisle.se>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'stats_and_connection_info' into 'master'
Daniel Lenski [Tue, 5 Jan 2021 17:17:30 +0000 (17:17 +0000)]
Merge branch 'stats_and_connection_info' into 'master'

add SIGUSR1 as trigger to print detailed connection information and stats

See merge request openconnect/openconnect!154

4 years agoMerge branch 'tncc_override_user_agent' into 'master'
Daniel Lenski [Tue, 5 Jan 2021 04:57:22 +0000 (04:57 +0000)]
Merge branch 'tncc_override_user_agent' into 'master'

tncc-emulate.py: add TNCC_USER_AGENT override variable

See merge request openconnect/openconnect!157

4 years agochangelog
Daniel Lenski [Tue, 8 Dec 2020 22:14:55 +0000 (14:14 -0800)]
changelog

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agodefer the switch to syslog until AFTER the tunnel is fully up,
Daniel Lenski [Tue, 5 Jan 2021 04:48:20 +0000 (20:48 -0800)]
defer the switch to syslog until AFTER the tunnel is fully up,

This way, initial connection information and background PID will be usefully
printed to the console, as will errors which prevent the tunnel from being
started (and thus cause OpenConnect to abort as soon as it's established
a connection to the server).

This is a further refinement of 557ac6cfa6d42045ac5ed5e65e2fb079106643fa (!117).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd SIGUSR1 as trigger to print detailed connection information and stats
Daniel Lenski [Thu, 3 Dec 2020 19:47:46 +0000 (11:47 -0800)]
add SIGUSR1 as trigger to print detailed connection information and stats

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'openconnect_get_auth_expiration' into 'master'
Daniel Lenski [Mon, 14 Dec 2020 22:49:03 +0000 (22:49 +0000)]
Merge branch 'openconnect_get_auth_expiration' into 'master'

add auth_expiration (AnyConnect, GP, Pulse) and openconnect_get_auth_expiration() API function

See merge request openconnect/openconnect!156

4 years agoimplement `auth_expiration` for Pulse protocol
Daniel Lenski [Wed, 9 Dec 2020 03:24:00 +0000 (19:24 -0800)]
implement `auth_expiration` for Pulse protocol

We have many examples of this field (AVP 0x583/0xd5c) being multiples of 60 or 3600,
strongly suggesting that it's the remaining auth lifetime:

- https://gitlab.com/openconnect/openconnect/-/issues/98: `AVP 0x583/0xd5c: 00 01 fa 40` (0x1fa40 seconds = 36 hours)
- private communication: `AVP 0x583/0xd5c: 00 00 a9 ec` (0xa9ec seconds = 12 hours)
- private communication: `AVP 0x583/0xd5c: 00 00 0a 70` (0xa70 seconds = 44 minutes)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoAdd `openconnect_get_auth_expiration` function to library and JNI
Daniel Lenski [Thu, 24 Sep 2020 23:54:57 +0000 (16:54 -0700)]
Add `openconnect_get_auth_expiration` function to library and JNI

This allows protocols to save the moment when a session's authentication
(`vpninfo->cookie`) is expected to expire and no longer be useful for
reconnection.

The motivation is to eventually allow front-ends to know whether
reauthentication is needed, or whether they should try using a cached
cookie.

Current state:

- AnyConnect protocol: expiration is determined from the CONNECT
  response header `X-CSTP-Session-Timeout-Remaining` (with
  `X-CSTP-Session-Timeout` or `X-CSTP-Lease-Duration` as upper bounds in its
  absence)
- GlobalProtect protocol: expiration is determined from the `<lifetime>` tag of
  the XML config.
- Juniper Network Connect protocol: no currently known way to determine
  expiration. The `DSID` cookie is a standard HTTP cookie, so perhaps its
  expiration timestamp is intended for this purpose; however, I can find
  no real-world case where it has an expiration timestamp set.
- None of the currently-supported protocols provide the expiration
  timestamp until the connection phase, so it can't be obtained for
  export by the `--authenticate` option.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agotncc-emulate.py: add TNCC_USER_AGENT override variable
Daniel Lenski [Sun, 13 Dec 2020 17:45:21 +0000 (09:45 -0800)]
tncc-emulate.py: add TNCC_USER_AGENT override variable

See https://gitlab.com/openconnect/openconnect/-/issues/207#note_465454559 for use case and discussion

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoinclude quit_reason in exit message
Daniel Lenski [Tue, 8 Dec 2020 22:16:19 +0000 (14:16 -0800)]
include quit_reason in exit message

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'GP_IPv6_baby_steps' into 'master'
Daniel Lenski [Wed, 9 Dec 2020 18:03:38 +0000 (18:03 +0000)]
Merge branch 'GP_IPv6_baby_steps' into 'master'

GP: ESP debug messages and more IPv6 baby steps

See merge request openconnect/openconnect!155

4 years agochangelog
Daniel Lenski [Tue, 8 Dec 2020 22:23:30 +0000 (14:23 -0800)]
changelog

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoGP: explicitly warn when server has a missing ESP configuration
Daniel Lenski [Mon, 30 Nov 2020 22:21:21 +0000 (14:21 -0800)]
GP: explicitly warn when server has a missing ESP configuration

I'm tired of OpenConnect getting blamed for lack of ESP connectivity when in
fact literally every example that has been investigated since 2017 turned
out to be due to a missing server configuration, broken server
configuration, or network UDP blockage.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoCSD XML tag and nostub are entirely protocol-specific and used in only one place
Daniel Lenski [Mon, 4 May 2020 04:12:12 +0000 (21:12 -0700)]
CSD XML tag and nostub are entirely protocol-specific and used in only one place

This patch replaces them with inline functions (modeled after gpst_os_name),
instead of storing them in the global `struct openconnect_info` object.

TODO: further clarify, separate, and consolidate protocol-specific data in
`struct openconnect_info`.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agolittle bit more GP IPv6 support
Daniel Lenski [Mon, 30 Nov 2020 20:59:14 +0000 (12:59 -0800)]
little bit more GP IPv6 support

Process <dns-v6>, <access-routes-v6>, and <exclude-access-routes-v6> tags, and only
show the long-winded "please report" message once.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'more_logging_around_Trojan_script_invocation' into 'master'
Daniel Lenski [Thu, 3 Dec 2020 23:34:07 +0000 (23:34 +0000)]
Merge branch 'more_logging_around_Trojan_script_invocation' into 'master'

more logging around Trojan script invocation (CSD/HIP/TNCC)

See merge request openconnect/openconnect!152

4 years agomore logging around Trojan script invocation (CSD/HIP/TNCC)
Daniel Lenski [Mon, 30 Nov 2020 06:41:12 +0000 (22:41 -0800)]
more logging around Trojan script invocation (CSD/HIP/TNCC)

See #203 for a recent example of where it wasn't clear that a problem was
caused by a CSD script being invoked and never returning, due to the lack of
logging.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'bugfix_MR_143' into 'master'
Daniel Lenski [Tue, 1 Dec 2020 16:41:21 +0000 (16:41 +0000)]
Merge branch 'bugfix_MR_143' into 'master'

bugfix for !143

See merge request openconnect/openconnect!153

4 years agofix undefined pointer error from !143
Daniel Lenski [Mon, 30 Nov 2020 20:35:17 +0000 (12:35 -0800)]
fix undefined pointer error from !143

Caught by static analyzer run.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'clarify_some_error_messages_which_apply_equally_to_TLS_and_DTLS_sockets...
Daniel Lenski [Mon, 30 Nov 2020 19:26:34 +0000 (19:26 +0000)]
Merge branch 'clarify_some_error_messages_which_apply_equally_to_TLS_and_DTLS_sockets' into 'master'

clarify some error messages which apply equally to TLS and DTLS sockets

See merge request openconnect/openconnect!149

4 years agoMerge branch 'GP_finesse_URL_decoding' into 'master'
Daniel Lenski [Mon, 30 Nov 2020 19:24:40 +0000 (19:24 +0000)]
Merge branch 'GP_finesse_URL_decoding' into 'master'

finesse the URL-decoding of the GP login args

See merge request openconnect/openconnect!143

4 years agoclarify some error messages which apply equally to TLS and DTLS sockets
Daniel Lenski [Mon, 30 Nov 2020 03:09:15 +0000 (19:09 -0800)]
clarify some error messages which apply equally to TLS and DTLS sockets

Clarifies #157 (but doesn't actually fix it)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'tmp-fix-centos7-failure' into 'master'
Nikos Mavrogiannopoulos [Thu, 19 Nov 2020 22:03:38 +0000 (22:03 +0000)]
Merge branch 'tmp-fix-centos7-failure' into 'master'

dtls-psk: use ping -6 to ping an ipv6 address

Closes #200

See merge request openconnect/openconnect!147

4 years ago.gitlab-ci.yml: CentosOS7/OpenSSL: mark failing test as XFAIL
Nikos Mavrogiannopoulos [Thu, 19 Nov 2020 21:24:51 +0000 (22:24 +0100)]
.gitlab-ci.yml: CentosOS7/OpenSSL: mark failing test as XFAIL

That's because the test was not functional until now (due to missing
'which' application).

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
4 years agodtls-psk: use ping -6 to ping an ipv6 address
Nikos Mavrogiannopoulos [Thu, 19 Nov 2020 20:55:56 +0000 (21:55 +0100)]
dtls-psk: use ping -6 to ping an ipv6 address

This is necessary in centos7 images.

Resolves: #200

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
4 years agoMerge branch 'GP_demangle_default_route_as_split_route' into 'master'
Daniel Lenski [Thu, 19 Nov 2020 18:23:16 +0000 (18:23 +0000)]
Merge branch 'GP_demangle_default_route_as_split_route' into 'master'

GP: Fix the issue of a 0.0.0.0/0 "split"-include route by swapping the "split" route with the default netmask.

See merge request openconnect/openconnect!118

4 years agoMerge branch 'GP_unexpected_value_of_connected-gw-ip' into 'master'
Daniel Lenski [Thu, 19 Nov 2020 18:19:38 +0000 (18:19 +0000)]
Merge branch 'GP_unexpected_value_of_connected-gw-ip' into 'master'

GP: ask user to report unexpected value of <connected-gw-ip>

See merge request openconnect/openconnect!144

4 years agoMerge branch 'enable_insecure_debugging' into 'master'
Daniel Lenski [Tue, 17 Nov 2020 20:29:22 +0000 (20:29 +0000)]
Merge branch 'enable_insecure_debugging' into 'master'

Enable insecure debugging

See merge request openconnect/openconnect!112

4 years agoMerge branch 'delay_tunnel_and_close' into 'master'
Daniel Lenski [Tue, 17 Nov 2020 20:26:55 +0000 (20:26 +0000)]
Merge branch 'delay_tunnel_and_close' into 'master'

delay_tunnel_reason and delay_close

See merge request openconnect/openconnect!117

4 years agoMerge branch 'tmp-add-scan-build' into 'master'
Nikos Mavrogiannopoulos [Tue, 17 Nov 2020 20:22:25 +0000 (20:22 +0000)]
Merge branch 'tmp-add-scan-build' into 'master'

Add clang's static analyzer to CI

See merge request openconnect/openconnect!139

4 years agoGP: ask user to report unexpected value of <connected-gw-ip>
Daniel Lenski [Sun, 15 Nov 2020 23:32:08 +0000 (15:32 -0800)]
GP: ask user to report unexpected value of <connected-gw-ip>

We don't know what this one means, but it seems likely that we need to do
some special processing if this differs from the VPN server's external IP
address.

See https://gitlab.com/openconnect/openconnect/-/issues/193#note_447466255
for an example of this field observed "in the wild".

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'less_confusing_output_when_authentication_fails' into 'master'
Daniel Lenski [Tue, 17 Nov 2020 19:41:31 +0000 (19:41 +0000)]
Merge branch 'less_confusing_output_when_authentication_fails' into 'master'

less confusing output when authentication fails

See merge request openconnect/openconnect!146

4 years agointernal_parse_url: fix memory leak
Nikos Mavrogiannopoulos [Mon, 16 Nov 2020 22:10:48 +0000 (23:10 +0100)]
internal_parse_url: fix memory leak

Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
4 years agontlm_manual_challenge: initialize hash to zero
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:18:04 +0000 (16:18 +0100)]
ntlm_manual_challenge: initialize hash to zero

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agognutls: removed unused assignments, and use gnutls_calloc()
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:15:17 +0000 (16:15 +0100)]
gnutls: removed unused assignments, and use gnutls_calloc()

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agoopenconnect_set_token_mode: propagate error code
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:07:30 +0000 (16:07 +0100)]
openconnect_set_token_mode: propagate error code

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agooncp_connect: avoid code without side-effects
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:06:15 +0000 (16:06 +0100)]
oncp_connect: avoid code without side-effects

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agoprocess_http_response: removed default error code
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:04:47 +0000 (16:04 +0100)]
process_http_response: removed default error code

It was not used by any of the code paths.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agooncp_connect: bail on error
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:04:04 +0000 (16:04 +0100)]
oncp_connect: bail on error

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agodecrypt_stoken: avoid code without side effects
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:03:10 +0000 (16:03 +0100)]
decrypt_stoken: avoid code without side effects

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agoappend_compr_types: removed unnecessary assignment
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:01:30 +0000 (16:01 +0100)]
append_compr_types: removed unnecessary assignment

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agobuf_tlv: corrected TLV decoding
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 15:00:24 +0000 (16:00 +0100)]
buf_tlv: corrected TLV decoding

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agodtls_detect_mtu: removed unnecessary initialization
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 14:58:26 +0000 (15:58 +0100)]
dtls_detect_mtu: removed unnecessary initialization

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agoparse_prelogin_xml: removed unnecessary initialization
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 14:57:51 +0000 (15:57 +0100)]
parse_prelogin_xml: removed unnecessary initialization

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agodo_https_request: removed unused assignment
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 14:55:31 +0000 (15:55 +0100)]
do_https_request: removed unused assignment

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agostart_cstp_connection: avoid unused assignment
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 14:54:19 +0000 (15:54 +0100)]
start_cstp_connection: avoid unused assignment

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agocleanup_gssapi_auth: avoid null pointer dereference
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 14:48:30 +0000 (15:48 +0100)]
cleanup_gssapi_auth: avoid null pointer dereference

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agoprocess_http_response: avoid memory leak
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 14:47:25 +0000 (15:47 +0100)]
process_http_response: avoid memory leak

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agorun_hip_script: made error handling consistent
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 14:36:06 +0000 (15:36 +0100)]
run_hip_script: made error handling consistent

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agoparse_hex: avoid zero length allocation
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 13:59:33 +0000 (14:59 +0100)]
parse_hex: avoid zero length allocation

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years ago.gitlab-ci.yml: added clang's static analyzer
Nikos Mavrogiannopoulos [Thu, 12 Nov 2020 13:44:32 +0000 (14:44 +0100)]
.gitlab-ci.yml: added clang's static analyzer

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
4 years agoMerge branch 'tmp-add-ubsan-asan' into 'master'
Nikos Mavrogiannopoulos [Tue, 17 Nov 2020 12:52:50 +0000 (12:52 +0000)]
Merge branch 'tmp-add-ubsan-asan' into 'master'

Add support for address and undefined sanitizers in the CI

See merge request openconnect/openconnect!140

4 years agoless confusing output when authentication fails
Daniel Lenski [Mon, 16 Nov 2020 22:00:47 +0000 (14:00 -0800)]
less confusing output when authentication fails

* "Failed to obtain WebVPN cookie" → "Failed to complete authentication"
  (WebVPN is Cisco-specific and unclear to end users)
* GlobalProtect shouldn't treat a SAML-required login response as a failure to *parse*
  the login response. This results in unnecessary and confusing logging. (ping #197)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agochangelog
Daniel Lenski [Thu, 15 Oct 2020 01:40:48 +0000 (18:40 -0700)]
changelog

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoreduce level of delay_tunnel/delay_close logging
Daniel Lenski [Thu, 21 May 2020 17:09:58 +0000 (10:09 -0700)]
reduce level of delay_tunnel/delay_close logging

See https://gitlab.com/openconnect/openconnect/-/merge_requests/117#note_346745240

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years ago-b/--background: check for error when fork()ing
Daniel Lenski [Mon, 16 Nov 2020 21:37:37 +0000 (13:37 -0800)]
-b/--background: check for error when fork()ing

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agouse setup_tun callback to defer printing connection status AND backgrounding until...
Daniel Lenski [Wed, 20 May 2020 05:06:34 +0000 (22:06 -0700)]
use setup_tun callback to defer printing connection status AND backgrounding until tun_is_up

This will make scripted use of OpenConnect a lot less sensitive to timing of the tunnel
coming up, if a script is trying to use the tunnel as soon as the main process exits.
(See https://gitlab.com/openconnect/openconnect/-/issues/117 for examples.)

Here's a log of OpenConnect connecting to a GlobalProtect server where ESP
fails to start succesfully due to a firewall blocking UDP. With this
change, it doesn't print the connection status or go to background until after the
attempt to connect ESP has failed, and the tunnel has been started.

    $ echo PASSWORD | sudo ./openconnect -u USERNAME vpn.company.com/gateway --prot=gp --passwd-on-stdin -b \
                           -s 'echo +++ vpnc-script called with reason $reason'
    POST https://vpn.company.com/ssl-vpn/prelogin.esp?tmp=tmp&clientVer=4100&clientos=Linux
    Connected to 1.2.3.4:443
    SSL negotiation with vpn.company.com
    Connected to HTTPS on vpn.company.com with ciphersuite (TLS1.2)-(RSA)-(AES-256-GCM)
    Enter login credentials
    POST https://vpn.company.com/ssl-vpn/login.esp
    POST https://vpn.company.com/ssl-vpn/getconfig.esp
    Session will expire after 1440 minutes.
    Tunnel timeout (rekey interval) is 180 minutes.
    Idle timeout is 180 minutes.
    No MTU received. Calculated 1214 for ESP tunnel
    POST https://vpn.company.com/ssl-vpn/hipreportcheck.esp
    Delaying tunnel for 1000 ms with reason: awaiting GPST ESP connection
    Delaying tunnel for 1000 ms with reason: awaiting GPST ESP connection
    Delaying tunnel for 1000 ms with reason: awaiting GPST ESP connection
    Delaying tunnel for 1000 ms with reason: awaiting GPST ESP connection
    Delaying tunnel for 1000 ms with reason: awaiting GPST ESP connection
    Delaying tunnel for 1000 ms with reason: awaiting GPST ESP connection
    Failed to connect ESP tunnel; using HTTPS instead.
    Connected as 10.0.1.2, using SSL, with ESP unsuccessful
    Continuing in background; pid 1234
    +++ vpnc-script called with reason pre-init
    +++ vpnc-script called with reason connect
    $

Here's an example of attempted DTLS connecting on an AnyConnect VPN, where DTLS
never succeeds. This right away gives us some good feedback that we could probably
reduce the duration of the loop:

    Connected to 1.2.3.4:443
    SSL negotiation with vpn.company.com
    Server certificate verify failed: signer not found
    Connected to HTTPS on vpn.company.com with ciphersuite (TLS1.2)-(ECDHE-RSA-SECP384R1)-(AES-256-GCM)
    Got CONNECT response: HTTP/1.1 200 OK
    CSTP connected. DPD 30, Keepalive 20
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    DTLS handshake failed: Resource temporarily unavailable, try again.
    Delaying tunnel for 1000 ms with reason: DTLS MTU detection
    Connected as 10.0.1.2, using SSL, with DTLS in progress

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofactor out print_connection_info()
Daniel Lenski [Wed, 20 May 2020 05:04:23 +0000 (22:04 -0700)]
factor out print_connection_info()

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agowe should still try to cleanly close the session if tun device creation fails
Daniel Lenski [Sun, 17 May 2020 00:09:24 +0000 (17:09 -0700)]
we should still try to cleanly close the session if tun device creation fails

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agouse delay_tunnel_reason for OC DTLS MTU detection and GPST ESP connection delays
Daniel Lenski [Wed, 20 May 2020 06:28:55 +0000 (23:28 -0700)]
use delay_tunnel_reason for OC DTLS MTU detection and GPST ESP connection delays

As suggested here: https://gitlab.com/openconnect/openconnect/-/commit/55ffb457010974c05096a78ac917692b7fac664b#note_343873848

There's no clear rationale for using with Pulse/oNCP ESP setup (yet):
- We don't do any MTU detection
- Unlike GPST, we can start sending and receiving packets via the TLS tunnel
  immediately, while attempting to connect ESP as well.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd delay_tunnel_reason and delay_close
Daniel Lenski [Sun, 17 May 2020 00:06:10 +0000 (17:06 -0700)]
add delay_tunnel_reason and delay_close

- As long as the protocol-specific mainloop sets delay_tunnel_reason to a non-NULL value, tunnel
  device creation will be delayed.

- If delay_close is set, mainloop will continue to iterate even if cancel_cmd or pause_cmd is set.

  A protocol should set DELAY_CLOSE_IMMEDIATE_CALLBACK for the case where its mainloop needs an
  immediate callback (e.g. to send some kind of termination request), and DELAY_CLOSE_WAIT for the
  case where its mainloop is waiting to receive something (e.g. a termination acknowledgement).

openconnect_mainloop() will unset both delay_tunnel_reason and delay_close on each iteration. A
protocol mainloop must thus affirmatively extend a delay in order for it to continue.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>