]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
6 years agoFall back to tpm2tss engine
David Woodhouse [Sat, 13 Oct 2018 03:34:59 +0000 (20:34 -0700)]
Fall back to tpm2tss engine

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoClean up ibmtss error reporting to use vpn_progress()
David Woodhouse [Fri, 12 Oct 2018 21:18:18 +0000 (14:18 -0700)]
Clean up ibmtss error reporting to use vpn_progress()

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoConsolidate tpm2_get_session_handle()
David Woodhouse [Fri, 12 Oct 2018 21:00:53 +0000 (14:00 -0700)]
Consolidate tpm2_get_session_handle()

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoClean up persistent/generated handle checks a little
David Woodhouse [Fri, 12 Oct 2018 20:53:29 +0000 (13:53 -0700)]
Clean up persistent/generated handle checks a little

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoReinstate support for TPM2 'TSS2 KEY BLOB' support with GnuTLS
David Woodhouse [Fri, 12 Oct 2018 19:25:35 +0000 (12:25 -0700)]
Reinstate support for TPM2 'TSS2 KEY BLOB' support with GnuTLS

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoRemove legacy tpm2tss PEM support
David Woodhouse [Fri, 12 Oct 2018 19:25:06 +0000 (12:25 -0700)]
Remove legacy tpm2tss PEM support

That format got removed before it was ever released...

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoRemove static ui_vpninfo hack for ENGINE callbacks
David Woodhouse [Fri, 12 Oct 2018 18:49:45 +0000 (11:49 -0700)]
Remove static ui_vpninfo hack for ENGINE callbacks

This doesn't seem to be needed; all the TPM engines (even v1) handle
the callback properly now.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agotpm2-esys: Check parent NODA flag and demand password if needed
David Woodhouse [Fri, 12 Oct 2018 17:34:33 +0000 (10:34 -0700)]
tpm2-esys: Check parent NODA flag and demand password if needed

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoSwitch to standard TSS2 PEM format
David Woodhouse [Fri, 12 Oct 2018 05:51:08 +0000 (22:51 -0700)]
Switch to standard TSS2 PEM format

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoFactor out PKCS#1 padding
David Woodhouse [Thu, 11 Oct 2018 20:34:58 +0000 (13:34 -0700)]
Factor out PKCS#1 padding

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoAdd tss2-devel to CI
David Woodhouse [Thu, 11 Oct 2018 01:09:40 +0000 (18:09 -0700)]
Add tss2-devel to CI

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoFirst cut at IBM TSS support, mostly copied from James's tpm2 engine.
David Woodhouse [Wed, 10 Oct 2018 22:19:33 +0000 (15:19 -0700)]
First cut at IBM TSS support, mostly copied from James's tpm2 engine.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoUpdate changelog. TPM2 is no longer OpenSSL-only.
David Woodhouse [Wed, 10 Oct 2018 19:22:47 +0000 (12:22 -0700)]
Update changelog. TPM2 is no longer OpenSSL-only.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoAdd support for persistent parent keys and other hierarchies
David Woodhouse [Wed, 10 Oct 2018 19:10:23 +0000 (12:10 -0700)]
Add support for persistent parent keys and other hierarchies

We should now be able to cope with anything James's tpm2 engine creates,
except for the policies.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoAllow parsing of permanent handles for TPM2 parents
David Woodhouse [Wed, 10 Oct 2018 19:09:13 +0000 (12:09 -0700)]
Allow parsing of permanent handles for TPM2 parents

These need to be returned in 5 bytes because they have the top
bit set and would otherwise be interpreted as negative.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoSkeleton IBM TSS support
David Woodhouse [Tue, 9 Oct 2018 10:06:16 +0000 (11:06 +0100)]
Skeleton IBM TSS support

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoMove non-TSS-specific code to gnutls_tpm2.c
David Woodhouse [Tue, 9 Oct 2018 09:01:07 +0000 (10:01 +0100)]
Move non-TSS-specific code to gnutls_tpm2.c

In preparation for potentially implementing a version using ibmtss.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoFix signedness handling for EC signatures
David Woodhouse [Tue, 9 Oct 2018 07:44:20 +0000 (08:44 +0100)]
Fix signedness handling for EC signatures

If R or S have the top bit set, we need to prepend a zero byte to prevent
them from being interpreted as negative.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoFactor out sign_hash functions for tpm2
David Woodhouse [Mon, 8 Oct 2018 19:14:17 +0000 (20:14 +0100)]
Factor out sign_hash functions for tpm2

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoAdd openconnect_set_key_password()
David Woodhouse [Mon, 8 Oct 2018 20:13:30 +0000 (21:13 +0100)]
Add openconnect_set_key_password()

For auto-provisioning via NetworkManager it's actually quite useful to be
able to set vpninfo->cert_password and have that special case handled,
instead of having to inject the password into the user's keyring somehow.

It's either that or revise the FSID hack...

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoAdd openconnect_has_tss2_blob_support()
David Woodhouse [Mon, 8 Oct 2018 20:06:33 +0000 (21:06 +0100)]
Add openconnect_has_tss2_blob_support()

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoUpdate licence and TPM docs
David Woodhouse [Mon, 8 Oct 2018 20:02:12 +0000 (21:02 +0100)]
Update licence and TPM docs

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoTell GnuTLS the TPM2 can't do SHA512
David Woodhouse [Thu, 4 Oct 2018 23:57:29 +0000 (00:57 +0100)]
Tell GnuTLS the TPM2 can't do SHA512

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoFix TPM2 emptyauth handling
David Woodhouse [Thu, 4 Oct 2018 23:57:08 +0000 (00:57 +0100)]
Fix TPM2 emptyauth handling

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoAdd TPM2 ECC support
David Woodhouse [Thu, 4 Oct 2018 13:00:25 +0000 (14:00 +0100)]
Add TPM2 ECC support

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoSupport TPM2 auth
David Woodhouse [Wed, 3 Oct 2018 22:40:00 +0000 (23:40 +0100)]
Support TPM2 auth

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoFirst pass at proper TPM2 support for GnuTLS using tss2-esys
David Woodhouse [Wed, 3 Oct 2018 20:19:44 +0000 (21:19 +0100)]
First pass at proper TPM2 support for GnuTLS using tss2-esys

Various caveats, including the complete lack of authentication, lack
of EC and policy support, hard-coded use of PKCS#1 padding, etc.

But hey, it works for my test case.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoParse TPM2 ASN.1 blob
David Woodhouse [Wed, 3 Oct 2018 14:46:26 +0000 (15:46 +0100)]
Parse TPM2 ASN.1 blob

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoPost CSD results even when no other auth is needed.
David Woodhouse [Mon, 8 Oct 2018 19:14:42 +0000 (20:14 +0100)]
Post CSD results even when no other auth is needed.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoMerge branch 'fix_authgroup_dropdown_handling' of gitlab.com:dlenski/openconnect
David Woodhouse [Mon, 8 Oct 2018 19:16:49 +0000 (20:16 +0100)]
Merge branch 'fix_authgroup_dropdown_handling' of gitlab.com:dlenski/openconnect

6 years agoFix GlobalProtect authgroup handling
Daniel Lenski [Mon, 8 Oct 2018 18:03:45 +0000 (11:03 -0700)]
Fix GlobalProtect authgroup handling

When connecting to a GlobalProtect server via the portal interface, then
`vpninfo->authgroup` needs to be set to the URL of one of the allowed
gateways.

The problem here is that if the user actually wanted to select the _first_
gateway in the dropdown list, it was already pre-selected, and thus clicking
"continue"/"login" on the form wouldn't trigger `OC_FORM_RESULT_NEWGROUP`.

This would prevent `vpninfo->authgroup` from getting set correctly, and the
gateway redirect would be skipped entirely.  Thus it was effectively
impossible to select the first option in the gateway dropdown.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoFix issue causing front-ends/GUIs to be insensitive to changes in the Juniper realm...
Daniel Lenski [Mon, 8 Oct 2018 17:39:54 +0000 (10:39 -0700)]
Fix issue causing front-ends/GUIs to be insensitive to changes in the Juniper realm dropdown

This has been a persistent, puzzling issue
(http://lists.infradead.org/pipermail/openconnect-devel/2018-July/004926.html,
http://lists.infradead.org/pipermail/openconnect-devel/2017-November/004558.html,
etc.).  When connecting to a Juniper VPN from a front-end (e.g.
NM-OpenConnect, OpenConnect-GUI for Windows, OpenConnect for Android),
changing the selected realm/`authgroup` in the drop-down box causes the form
to immediately reload *without* saving the change.

This turned out to be a rather subtle issue…

The meaning and usage of `vpninfo->authgroup` differs across the different
protocols, which made this hard to isolate.

* With AnyConnect, changing the authgroup value in the form is supposed to
  trigger an immediate reload of the form, since the form contents can
  differ from one authgroup to another.  Hence a `process_auth_form`
  callback should immediately return `OC_FORM_RESULT_NEWGROUP` when the form
  value changes.
* With Juniper, the authgroup dropdown don't *actually* need to trigger a reloading
  of the form, since the form won't change if the authgroup field changes.
  (At least not on any Juniper VPN I have access to.) However, it doesn't
  hurt anything either, and setting the dropdown as `form->authgroup_opt`
  allows CLI users to specify the desired setting with `--authgroup`, which
  is very convenient.
* With GlobalProtect, the authgroup has been repurposed to represent the desired
  *gateway* to connect to, in the cases where the user is connecting via the
  *portal* interface.  The authgroup selection always appears in a form by
  itself, currently.  This similarly allows CLI users to pick the desired
  gateway with `--authgroup`.

Long story short, the problem here was that `form->authgroup_selection`
needed to be set to a specific index (within `form->authgroup_opt->choices[]`)
 of the currently selected value, in order
for the GUI to show the right value as selected.  If this wasn't set, then
every time the selection was changed (causing the form handler to return
`OC_FORM_RESULT_NEWGROUP`), the selected index would revert to `0` on the
next iteration of the form.

For AnyConnect, the `form->authgroup_selection` was already set correctly;
for Juniper and GlobalProtect, it wasn't.  It seems to me that the most
robust fix here is to ensure that `process_auth_form` itself always sets
`form->authgroup_selection` to the index of the value matching
`vpninfo->authgroup` _before_ handing the form off `process_auth_form_cb`.

Tested that this change makes Juniper realm dropdowns work correctly in the
NM-OpenConnect and Android front-ends.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoMerge branch 'multiple_search_domains_GPST' into 'master'
David Woodhouse [Sat, 6 Oct 2018 08:26:32 +0000 (08:26 +0000)]
Merge branch 'multiple_search_domains_GPST' into 'master'

Don't segfault when search domain list is empty (and thus `domains->pos == 0`)

See merge request openconnect/openconnect!11

6 years agoDon't segfault when search domain list is empty (and thus `domains->pos == 0`)
Daniel Lenski [Sat, 6 Oct 2018 04:36:38 +0000 (21:36 -0700)]
Don't segfault when search domain list is empty (and thus `domains->pos == 0`)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoUpdate TPM documentation to mention TPMv2
David Woodhouse [Wed, 3 Oct 2018 08:09:36 +0000 (09:09 +0100)]
Update TPM documentation to mention TPMv2

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoAdd shell of TPM2 support
David Woodhouse [Thu, 27 Sep 2018 12:59:19 +0000 (14:59 +0200)]
Add shell of TPM2 support

This doesn't do anything useful at all yet. It would be nice if the two
available OpenSSL engines were actually compatible.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoShift TSS context out of generic vpninfo
David Woodhouse [Mon, 1 Oct 2018 11:51:20 +0000 (12:51 +0100)]
Shift TSS context out of generic vpninfo

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoShift PC/SC context out of generic vpninfo
David Woodhouse [Mon, 1 Oct 2018 11:01:00 +0000 (12:01 +0100)]
Shift PC/SC context out of generic vpninfo

TPM2 support wants its own BOOL definition which conflicts with the
"standard" Windows one from libpcsc. Let's just isolate things so that
we only need to include PC/SC header files from within yubikey.c.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoMake yubikey less picky about what it'll generate tokens for
David Woodhouse [Wed, 3 Oct 2018 07:06:52 +0000 (08:06 +0100)]
Make yubikey less picky about what it'll generate tokens for

The protocol should validate which form fields are OK; no need to apply
CSTP-specific filters (which are now out of date) in the yubikey code.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoMerge branch 'master' of gitlab.com:j.l-w/openconnect into HEAD
David Woodhouse [Wed, 3 Oct 2018 07:02:54 +0000 (08:02 +0100)]
Merge branch 'master' of gitlab.com:j.l-w/openconnect into HEAD

6 years agoAdd support for files from the *other* OpenSSL TPM2 engine. FFS.
David Woodhouse [Wed, 3 Oct 2018 06:59:12 +0000 (07:59 +0100)]
Add support for files from the *other* OpenSSL TPM2 engine. FFS.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoRecognise auth forms named "challenge" as token requests
James Laird-Wah [Wed, 18 Jul 2018 06:02:36 +0000 (16:02 +1000)]
Recognise auth forms named "challenge" as token requests

This was found in the wild on an AnyConnect instance which is hooked up
to a Microsoft 2FA platform.

Signed-off-by: James Laird-Wah <james-oc@laird-wah.net>
6 years agoAdd Changelog for OpenSSL TPM2 support
David Woodhouse [Mon, 1 Oct 2018 10:28:23 +0000 (11:28 +0100)]
Add Changelog for OpenSSL TPM2 support

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoGlobalProtect: query and parse prelogin.esp and use it to build auth forms, including...
Daniel Lenski [Sat, 8 Sep 2018 05:22:40 +0000 (22:22 -0700)]
GlobalProtect: query and parse prelogin.esp and use it to build auth forms, including preliminary SAML support

Until recently, I've believed the prelogin.esp to be useless, because the
initial GlobalProtect login form always contains the same two fields:
username and password.

However, the prelogin response is also important for signalling when SAML
login is required.  When the VPN uses SAML login, the official GP clients
redirect the user to a web-based authentication flow (e.g.  Okta,
https://github.com/dlenski/openconnect/issues/116).

That auth flow eventually sends the official client back to the GP VPN,
armed with a special cookie field, `portal-userauthcookie` or
`prelogin-cookie`, that needs to be submitted in place of the password
(already supported by openconnect as of 8b2bc5f22dda).

This preliminary SAML support simply includes the SAML method and URL in the
form banner, and fails with an error message if the cookie field name was
not specified (since it cannot be autodetected).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agosimplify gpst_xml_or_error handling and config parsing
Daniel Lenski [Sat, 8 Sep 2018 05:01:58 +0000 (22:01 -0700)]
simplify gpst_xml_or_error handling and config parsing

* replace GPST-specific xmlnode_get_text() with global xmlnode_get_val(), and make it free existing values (simplifies config loading)
* don't deal with numeric error codes in gpst_xml_or_error, only parsing
* make gpst_xml_or_error take 2 calbacks: one for XML, one for challenge (whether in XML or JavaScript form)
* allow callbacks to take cb_data
* use all this to simplify form handling

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agocatch 'Valid client certificate is required' as EPERM
Daniel Lenski [Sat, 8 Sep 2018 20:51:26 +0000 (13:51 -0700)]
catch 'Valid client certificate is required' as EPERM

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agohandle multiple search domains for GPST
Daniel Lenski [Fri, 28 Sep 2018 17:22:11 +0000 (10:22 -0700)]
handle multiple search domains for GPST

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoUse OpenSSL TPM2 engine
David Woodhouse [Thu, 27 Sep 2018 11:25:17 +0000 (13:25 +0200)]
Use OpenSSL TPM2 engine

We should look at whether we want to do this natively (probably not; we
should rely on the OpenSSL STORE mechanism instead), and we should
definitely look at how we're going to do it for GnuTLS. But this is a
start...

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoGPST should follow --csd-user, as done by CSTP
Daniel Lenski [Fri, 21 Sep 2018 18:41:00 +0000 (11:41 -0700)]
GPST should follow --csd-user, as done by CSTP

Code to set UID, GID according to csd_user was factored out into set_csd_user().

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoMerge branch 'fill_in_any_password_type_field' into 'master'
David Woodhouse [Fri, 21 Sep 2018 10:35:57 +0000 (10:35 +0000)]
Merge branch 'fill_in_any_password_type_field' into 'master'

command-line client should fill in any password-type field with value supplied via --passwd-on-stdin

See merge request openconnect/openconnect!6

6 years agocommand-line client should fill in any password field with value supplied via --passw...
Daniel Lenski [Wed, 5 Sep 2018 19:44:25 +0000 (12:44 -0700)]
command-line client should fill in any password field with value supplied via --passwd-on-stdin

I previously proposed adding form field hints to suggest which fields should
be populated with username/password values.  David Woodhouse was hesitant to
accept this and we settled on matching the form field names by the first
four characters ("user", "pass") as a temporary compromise:

    http://lists.infradead.org/pipermail/openconnect-devel/2017-August/004458.html

There's at least one specific case where this interferes with the
usage of the command-line client: some GlobalProtect users need to
specify an "alternative secret field" instead of the default "passwd"
field (using `--usergroup :field_name`).

Because this field's name normally doesn't start with "pass", openconnect
won't accept it via `--passwd-on-stdin`:

    script_to_do_fancy_GlobalProtect_SAML_login |
      openconnect --protocol=gp -u user --passwd-on-stdin --usergroup portal:portal_cookie_field_name globalprotect.company.com

As far as I can tell, there's not actually any good reason why openconnect
should *only* fill in a password-type field with the supplied password
if its name starts with "pass", so we should get rid of that check.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoMerge branch 'master' of gitlab.com:KyleJ61782/openconnect
David Woodhouse [Fri, 21 Sep 2018 07:36:36 +0000 (08:36 +0100)]
Merge branch 'master' of gitlab.com:KyleJ61782/openconnect

6 years agoMerge branch 'fix_base64_decode' of gitlab.com:dlenski/openconnect
David Woodhouse [Fri, 21 Sep 2018 07:30:18 +0000 (08:30 +0100)]
Merge branch 'fix_base64_decode' of gitlab.com:dlenski/openconnect

6 years agoMerge branch 'gp_always_clientos_Windows' into 'master'
David Woodhouse [Fri, 21 Sep 2018 07:26:43 +0000 (07:26 +0000)]
Merge branch 'gp_always_clientos_Windows' into 'master'

Always set `clientos=Windows` in GlobalProtect requests

See merge request openconnect/openconnect!5

6 years agoGlobalProtect: always set clientos=Windows in relevant requests, regardless of actual OS
Daniel Lenski [Wed, 5 Sep 2018 04:58:08 +0000 (21:58 -0700)]
GlobalProtect: always set clientos=Windows in relevant requests, regardless of actual OS

I've tried, whenever possible not to lie to the server about the client
configuration.  However, there are now multiple cases where a GlobalProtect
server responds with a misleading error when the `ssl-vpn/login.esp` request doesn't
contain the exact, magic value of `clientos=Windows`.

* https://github.com/dlenski/openconnect/issues/86
  ("Assign private IP address failed" unless `clientos=Windows` in `ssl-vpn/login.esp` request)

* https://github.com/dlenski/openconnect/issues/116
  ("Invalid username or password" unless `clientos=Windows` in `ssl-vpn/login.esp` request)

These cases are very difficult to debug because they seem to be suggesting totally unrelated
errors.

For reliability, this patch makes openconnect always specify `clientos=Windows` in relevant
requests, regardless of the actual `vpninfo->platname`. (The `vpninfo->platname` value can
still be sent in the "free-form" `os-version` field, as far as I can tell.)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoUpdate translations from GNOME
David Woodhouse [Mon, 17 Sep 2018 18:48:00 +0000 (19:48 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoopenconnect_base64_decode: fix sign of error return value
Daniel Lenski [Fri, 7 Sep 2018 22:49:05 +0000 (15:49 -0700)]
openconnect_base64_decode: fix sign of error return value

6 years agoToggle TAP status to force Windows to re-run NLA.
Kyle Johnson [Sat, 1 Sep 2018 20:20:52 +0000 (15:20 -0500)]
Toggle TAP status to force Windows to re-run NLA.

Windows runs Network Location Awareness detection during the connection process
and sometimes fails because the connection script hasn't had an opportunity to
set up the connection enough for detection to work properly. Toggling the media
status forces re-detection which then occurs successfully.

Signed-off-by: Kyle Johnson <KyleJ61782@gmail.com>
6 years agoUpdate translations from GNOME
David Woodhouse [Wed, 15 Aug 2018 20:18:18 +0000 (21:18 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoallow overriding User-Agent in Java library
Daniel Lenski [Fri, 10 Aug 2018 17:03:12 +0000 (10:03 -0700)]
allow overriding User-Agent in Java library

Juniper servers do extra stupid things when "Java" appears in the UA string

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoRevert "Don't treat Juniper 'realm' field as authgroup"
David Woodhouse [Thu, 9 Aug 2018 19:44:15 +0000 (20:44 +0100)]
Revert "Don't treat Juniper 'realm' field as authgroup"

This reverts commit b0a50a7e80e9b6a2d8aaa44c74b350a4aab51dc7.

6 years agoCheck whether glibtoolize is available in addition to libtoolize
Joerg Mayer [Thu, 9 Aug 2018 13:38:06 +0000 (15:38 +0200)]
Check whether glibtoolize is available in addition to libtoolize

macOS doesn't have libtoolize and GNU libtool only installs glibtoolize.

Signed-off-by: Joerg Mayer <jmayer@loplof.de>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoMerge branch 'feature/update-dnf-yum-cache' of gitlab.com:horar/openconnect
David Woodhouse [Thu, 9 Aug 2018 10:58:13 +0000 (11:58 +0100)]
Merge branch 'feature/update-dnf-yum-cache' of gitlab.com:horar/openconnect

6 years agoDon't treat Juniper 'realm' field as authgroup
David Woodhouse [Thu, 9 Aug 2018 10:27:08 +0000 (11:27 +0100)]
Don't treat Juniper 'realm' field as authgroup

The only point in the authgroup thing for the UI is to allow OpenConnect
to re-request the set of query fields for the new group. But the Juniper
protocol doesn't do that, and it's causing problems.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoMerge branch 'master' of gitlab.com:dlenski/openconnect
David Woodhouse [Thu, 9 Aug 2018 10:17:53 +0000 (11:17 +0100)]
Merge branch 'master' of gitlab.com:dlenski/openconnect

6 years agoAdd alternative CSD script to post results directly
David Woodhouse [Thu, 9 Aug 2018 10:10:01 +0000 (11:10 +0100)]
Add alternative CSD script to post results directly

This is a lot faster and more reliable than the Cisco crap.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoClean up csd-wrapper.sh
David Woodhouse [Thu, 9 Aug 2018 09:58:16 +0000 (10:58 +0100)]
Clean up csd-wrapper.sh

 • Only download files which need it
 • Add -k to curl when using pinned keys

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoProvide unique hostname to CSD script
David Woodhouse [Thu, 9 Aug 2018 09:56:21 +0000 (10:56 +0100)]
Provide unique hostname to CSD script

We see failures when DNS gives us a different IP address and the CSD
trojan ends up talking to a different host to the one we're actually
trying to authenticate to. Since we use pinned certificate hashes, it
shouldn't matter that we lose the hostname and can't validate the cert
against it.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoMerge branch 'include_csd-wrapper.sh' of gitlab.com:dlenski/openconnect
David Woodhouse [Thu, 9 Aug 2018 08:46:57 +0000 (09:46 +0100)]
Merge branch 'include_csd-wrapper.sh' of gitlab.com:dlenski/openconnect

6 years agoadd protocol-agnostic idle_timeout and openconnect_get_idle_timeout() API function
Daniel Lenski [Mon, 6 Aug 2018 20:06:07 +0000 (13:06 -0700)]
add protocol-agnostic idle_timeout and openconnect_get_idle_timeout() API function

This is needed for the Android GUI to detect the idle/keepalive interval in a cross-protocol way.

6 years agofix misuse of write_new_config callback by GP, causing Java crashes
Daniel Lenski [Mon, 6 Aug 2018 19:22:27 +0000 (12:22 -0700)]
fix misuse of write_new_config callback by GP, causing Java crashes

6 years agoUse waitpid() in a portable fashion
Daniel Lenski [Mon, 6 Aug 2018 07:48:01 +0000 (00:48 -0700)]
Use waitpid() in a portable fashion

The status value set by waitpid() needs to be manipulated using
WIFEXITED() and WEXITSTATUS() macros to be portable.

6 years agodescribe and set protocol in Java test application
Daniel Lenski [Sun, 5 Aug 2018 22:41:29 +0000 (15:41 -0700)]
describe and set protocol in Java test application

6 years agofix segfault in Java library test application
Daniel Lenski [Sun, 5 Aug 2018 23:05:06 +0000 (16:05 -0700)]
fix segfault in Java library test application

calling the Java method setCSDWrapper(String wrapper, String TMPDIR, String
PATH) with null TMPDIR and PATH would cause a segfault because
openconnect_set_csd_wrapper(vpninfo, name, value) requires a non-NULL value

6 years agoadd getProtocol, setProtocol, getSupportedProtocols, and VPNProto to Java bindings
Daniel Lenski [Sun, 5 Aug 2018 22:33:42 +0000 (15:33 -0700)]
add getProtocol, setProtocol, getSupportedProtocols, and VPNProto to Java bindings

6 years agoinclude openconnect_get_protocol method for completeness
Daniel Lenski [Sun, 5 Aug 2018 22:25:36 +0000 (15:25 -0700)]
include openconnect_get_protocol method for completeness

6 years agoadd missing OC_PROTO_CSD flag to GP protocol
Daniel Lenski [Sun, 5 Aug 2018 23:33:57 +0000 (16:33 -0700)]
add missing OC_PROTO_CSD flag to GP protocol

Should have been in "Add support for checking and submitting HIP reports" on 4 March 2018 (4e35d505314ec0bb940fcadde25f540da38a2e11)

6 years agoinclude computer name in the GP cookie
Daniel Lenski [Sat, 4 Aug 2018 03:01:26 +0000 (20:01 -0700)]
include computer name in the GP cookie

The GlobalProtect "cookie" is an overstuffed monstrosity, due to the
requirement to retain a few random, non-secret values in order to logout
successfully (see gpst_bye):

    authcookie=d41d8cd98f00b204e9800998ecf8427e&portal=Gateway-X&user=user.name&domain=big-corp

Until now, I've avoided including the computer field in this cookie, on the assumption that it
can reproduced at any time using vpninfo->localname. However, it appears that this value can't always
be reproduced correctly when running under NetworkManager:

    https://github.com/dlenski/network-manager-openconnect/issues/7

In order to be more robust, this patch therefore also includes the local hostname in the cookie:

    authcookie=d41d8cd98f00b204e9800998ecf8427e&portal=Gateway-X&user=user.name&domain=big-corp&computer=hostname

6 years agoRemove first oNCP negotiation request (only second is necessary)
Daniel Lenski [Thu, 2 Aug 2018 19:10:45 +0000 (12:10 -0700)]
Remove first oNCP negotiation request (only second is necessary)

The current oNCP (Juniper) protocol support issues two separate
oNCP negotiation requests.

1) POST /dana/js?prot=1&svc=1 HTTP/1.1
   <ignore response body>
   <teardown and restart TLS connection>

2) POST /dana/js?prot=1&svc=4 HTTP/1.1
   <continue using open TLS connection for oNCP tunnel>

The first of these two requests appears to be totally unnecessary, based on
testing with two different Juniper gateways, one of which returns
"NCP-Version: 2" and one which returns "NCP-Version: 3" in response to the
oNCP negotiation requests.

Removing the first request saves an additional TLS negotiation (2-3
roundtrips with TLS 1.0) and allows the connection to start faster.

6 years agoReduce unnecessary connection-rebuilding for Juniper
Daniel Lenski [Thu, 2 Aug 2018 19:10:45 +0000 (12:10 -0700)]
Reduce unnecessary connection-rebuilding for Juniper

The current oNCP (Juniper) protocol support sets "Connection: close" in all
HTTP requests.  This is not ideal because it requires many TLS handshakes
and round-trips, making the connection very slow to start when the latency
of the connection to the gateway is high, especially if the number of
authentication forms and redirects is large.

Simply removing the "Connection: close" header causes the oNCP connection
to fail; the server doesn't interpret the first packet sent over the oNCP
tunnel correctly (the vestigial authentication packet).

However, it appears that the "Connection: close" header *only* needs to be
specified for this final HTTP request, and not for any of the prior ones.
The presence of this header seems to signal to the gateway that it should
stop treating this as an HTTP connection, and start treating it as an
oNCP tunnel.

Tested on two different Juniper gateways, one which returns
"NCP-Version: 2" and one which returns "NCP-Version: 3" in response to
the oNCP negotiation requests.

6 years agoFill in a few missing references to GlobalProtect, TNCC, and DTLS support in the...
Daniel Lenski [Thu, 2 Aug 2018 01:25:13 +0000 (18:25 -0700)]
Fill in a few missing references to GlobalProtect, TNCC, and DTLS support in the docs

Also clarifies the command-line options regarding compression

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoClarify protocol description in connection message
Daniel Lenski [Thu, 2 Aug 2018 01:13:59 +0000 (18:13 -0700)]
Clarify protocol description in connection message

- Include both the TCP- and UDP-based protocols' compression details
- The UDP-based protocol really can't be connected by the time this
  prints, since the mainloop hasn't had enough time to receive the
  connection confirmation packets; show it as "in progress"

Before (with default verbosity):

    Connected as 10.0.0.3 + dead::be:ef, using SSL + deflate
    Established DTLS connection (using GnuTLS). Ciphersuite (DTLS1.2)-(RSA)-(AES-128-GCM).

After:

    Connected as 10.0.0.3 + dead::be:ef, using SSL + Deflate, with DTLS + LZS in progress
    Established DTLS connection (using GnuTLS). Ciphersuite (DTLS1.2)-(RSA)-(AES-128-GCM).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoClarify a few uncommented corners of the ESP support
Daniel Lenski [Thu, 2 Aug 2018 01:28:01 +0000 (18:28 -0700)]
Clarify a few uncommented corners of the ESP support

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoAlign naming and commenting of mechanism for receiving oversize packets across protocols
Daniel Lenski [Wed, 1 Aug 2018 02:35:59 +0000 (19:35 -0700)]
Align naming and commenting of mechanism for receiving oversize packets across protocols

We've now implemented mechanisms to tolerate larger-than-expected packets for:

  - Uncompressed CSTP packets ("Fixed regression with CSTP MTU handling"
    patch in July 2016)

  - Uncompressed oNCP packets ("Do not drop vpn connection if packet arrived
    is larger than MTU" patch in May 2017)

  - Uncompressed GPST packets (in original merge from March 2018; this is a
    virtual necessity for GlobalProtect because it has no functional
    mechanism for negotiating the MTU)

  - Uncompressed ESP packets ("check for oversize ESP packets, with 256
    bytes of headroom above calculated" in March 2018; GlobalProtect requires
    this for the aforementioned reason)

  - Compressed CSTP packets (preceding patch in this series)

Since this is a requiring issue across protocols, it's useful to align the
naming, commenting, and packet sizing-tolerance across the source files.

  1) Use receive_mtu everywhere as the name for the maximum tolerated size of an
     incoming packet.
  2) Insert similar comments explaining its purpose everywhere it's used.
  3) Use receive_mtu = MAX(16384, vpninfo->ip_info.mtu) for all TLS-based
     tunnels, because 16384 is the maximum TLS record size.
  4) Use receive_mtu = MAX(2048, vpninfo->vpninfo->ip_info.mtu + 256) for
     all UDP-based tunnels, because the MTU of IP datagrams on the public
     internet is effectively ~1500.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoTolerate packets that are larger than negotiated MTU after decompression
Daniel Lenski [Wed, 1 Aug 2018 02:32:26 +0000 (19:32 -0700)]
Tolerate packets that are larger than negotiated MTU after decompression

In July 2016, the "Fixed regression with CSTP MTU handling" patch
(http://git.infradead.org/users/dwmw2/openconnect.git/commitdiff/90e1555494dbc1cf462552679f9aa3d30451d123)
allowed openconnect to gracefully handle uncompressed CSTP packets larger
than the negotiated MTU.

This patch extends that approach to tolerate compressed packets which are
larger than the negotiated MTU after decompression.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoAdd changelog entries for other significant changes since v7.08
Daniel Lenski [Thu, 26 Jul 2018 18:16:22 +0000 (11:16 -0700)]
Add changelog entries for other significant changes since v7.08

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoUpdate yum/dnf cache before package installation
Ľubomír Carik [Thu, 12 Jul 2018 16:27:54 +0000 (18:27 +0200)]
Update yum/dnf cache before package installation

Let use most recent version of packages for building/testing.

Signed-off-by: Ľubomír Carik <Lubomir.Carik@gmail.com>
6 years agoopenconnect.8: reference ocserv(8)
Nikos Mavrogiannopoulos [Tue, 26 Jun 2018 00:32:09 +0000 (02:32 +0200)]
openconnect.8: reference ocserv(8)

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
6 years agoUpdate translations from GNOME
David Woodhouse [Thu, 7 Jun 2018 15:54:15 +0000 (16:54 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agoprovide CSD_SHA256 via environment variable rather than command-line argument
Daniel Lenski [Fri, 1 Jun 2018 19:13:57 +0000 (22:13 +0300)]
provide CSD_SHA256 via environment variable rather than command-line argument

David Woodhouse pointed out that -scert_256 might cause the old, non-XMLPOST CSD trojan to misbehave

6 years agoOops, leftover wget flag
Daniel Lenski [Thu, 31 May 2018 20:10:41 +0000 (20:10 +0000)]
Oops, leftover wget flag

6 years agoUpdate translations from GNOME
David Woodhouse [Thu, 31 May 2018 18:44:57 +0000 (19:44 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agouse curl with --pinnedpubkey to rely on sha256 hash of peer cert passed by openconnect
Daniel Lenski [Thu, 31 May 2018 18:11:47 +0000 (21:11 +0300)]
use curl with --pinnedpubkey to rely on sha256 hash of peer cert passed by openconnect

6 years agoMerge branch 'feature/cleanup_options_list' into 'master'
David Woodhouse [Thu, 31 May 2018 16:37:50 +0000 (16:37 +0000)]
Merge branch 'feature/cleanup_options_list' into 'master'

cleanup options list and make it less AnyConnect-specific

See merge request dwmw2/openconnect!2

6 years agoupdate csd-wrapper.sh to use -url argument, kill cstub after timeout, and fix small...
Daniel Lenski [Thu, 27 Oct 2016 22:59:47 +0000 (15:59 -0700)]
update csd-wrapper.sh to use -url argument, kill cstub after timeout, and fix small typos

6 years agoinclude default csd-wrapper.sh
Nikolay Panin [Thu, 31 May 2018 16:14:52 +0000 (19:14 +0300)]
include default csd-wrapper.sh

originally from https://gist.github.com/l0ki000/56845c00fd2a0e76d688

6 years agocheck for oversize ESP packets, with 256 bytes of headroom above calculated MTU
Daniel Lenski [Tue, 27 Mar 2018 15:39:58 +0000 (08:39 -0700)]
check for oversize ESP packets, with 256 bytes of headroom above calculated MTU

Because GlobalProtect VPNs have no practical mechanism for negotiating the
MTU whatsoever, it is entirely based on a client-side guess.  Therefore,
extra headroom is needed to reliably receive packets via both the HTTPS and
the ESP tunnels.

A similar patch by Nikolay Martynov <mar.kolya@gmail.com> was originally
applied for the Juniper HTTPS tunnel:
http://lists.infradead.org/pipermail/openconnect-devel/2017-May/004320.html

And similar functionality was incorporated into the GlobalProtect HTTPS
tunnel as well (gpst.c).

This patch adds the extra headroom for the ESP tunnel (used by both Juniper
and GlobalProtect VPNs) as well, after unexpectedly-large ESP packets were
observed "in the wild":
https://github.com/dlenski/openconnect/issues/96

Signed-off-by: Dan Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agofix typo in Juniper TOTP form name
Daniel Lenski [Thu, 31 May 2018 15:25:15 +0000 (18:25 +0300)]
fix typo in Juniper TOTP form name

There's a thread from November 2017 in which Kevin Cernekee and Andy
Wang discuss a Juniper VPN where TOTP fails to work:
http://lists.infradead.org/pipermail/openconnect-devel/2017-November/004569.html

… and in that thread both "ftmTotpToken" and "frmTotpToken" are
mentioned. It appears that the reason for the misbehavior discussed in
the November 2017 is because of the (overlooked) typo in the code.

I'm not sure how the "ftm" version got committed in the first
place. ¯\_(ツ)_/¯. I did a bit of archeological digging, and I can't
find the original patch (from November 29, 2016) anywhere on the
mailing list, but it's obviously in the Git history:
http://git.infradead.org/users/dwmw2/openconnect.git/commitdiff/1ff34cb9689fbaf57decac537df1e32e799bb9c7

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
6 years agomake the descriptions for the behavior of some command-line flags less AnyConnect...
Daniel Lenski [Sat, 21 Apr 2018 23:22:52 +0000 (16:22 -0700)]
make the descriptions for the behavior of some command-line flags less AnyConnect-specific

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
6 years agoadd section headers to listing of command-line options
Daniel Lenski [Thu, 31 May 2018 15:52:01 +0000 (18:52 +0300)]
add section headers to listing of command-line options

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