]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
3 years agoMerge branch 'epoll' of gitlab.com:openconnect/openconnect
David Woodhouse [Tue, 29 Jun 2021 17:40:46 +0000 (18:40 +0100)]
Merge branch 'epoll' of gitlab.com:openconnect/openconnect

3 years agoUse epoll() instead of select()
David Woodhouse [Tue, 29 Jun 2021 13:56:00 +0000 (14:56 +0100)]
Use epoll() instead of select()

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoMerge branch 'GP_portal_to_gateway_auth_with_cookies' into 'master'
David Woodhouse [Tue, 29 Jun 2021 11:49:47 +0000 (11:49 +0000)]
Merge branch 'GP_portal_to_gateway_auth_with_cookies' into 'master'

Pass the `portal-*cookie` values received in the portal config to the gateway login

Closes #147

See merge request openconnect/openconnect!199

3 years agoMerge branch 'rondom-do-https-request-header-cb' into 'master'
David Woodhouse [Tue, 29 Jun 2021 11:30:49 +0000 (11:30 +0000)]
Merge branch 'rondom-do-https-request-header-cb' into 'master'

http: Allow passing header_cb to do_https_request

See merge request openconnect/openconnect!201

3 years agoMerge branch 'vpnc-script_links_on_GitLab' into 'master'
David Woodhouse [Tue, 29 Jun 2021 11:27:24 +0000 (11:27 +0000)]
Merge branch 'vpnc-script_links_on_GitLab' into 'master'

Docs should link to Gitlab as the main repository for vpnc-script and vpnc-script-win.js

See merge request openconnect/openconnect!213

3 years agoMerge branch 'suspect_code_indent' into 'master'
David Woodhouse [Tue, 29 Jun 2021 11:26:42 +0000 (11:26 +0000)]
Merge branch 'suspect_code_indent' into 'master'

Fix Linux kernel coding style errors and warnings reported by checkpatch.pl

See merge request openconnect/openconnect!212

3 years agoMerge branch 'obey_IPv6_in_Pulse_and_Fortinet' into 'master'
David Woodhouse [Tue, 29 Jun 2021 11:24:47 +0000 (11:24 +0000)]
Merge branch 'obey_IPv6_in_Pulse_and_Fortinet' into 'master'

Follow disable_ipv6 for Pulse and Fortinet

See merge request openconnect/openconnect!214

3 years agoMerge branch 'small_PPP_fixes' into 'master'
David Woodhouse [Tue, 29 Jun 2021 11:24:17 +0000 (11:24 +0000)]
Merge branch 'small_PPP_fixes' into 'master'

small PPP fixes

See merge request openconnect/openconnect!216

3 years agoMerge branch 'update_authenticate_docs_for_RESOLVE_and_CONNECT_URL' into 'master'
David Woodhouse [Tue, 29 Jun 2021 11:22:15 +0000 (11:22 +0000)]
Merge branch 'update_authenticate_docs_for_RESOLVE_and_CONNECT_URL' into 'master'

update --authenticate docs to explain $RESOLVE and $CONNECT_URL

See merge request openconnect/openconnect!219

3 years agoMerge branch 'vpnc-script_s' into 'master'
David Woodhouse [Tue, 29 Jun 2021 11:15:49 +0000 (11:15 +0000)]
Merge branch 'vpnc-script_s' into 'master'

Fix URL of repository of vpnc-script

See merge request openconnect/openconnect!227

3 years agoFix open brace '{' following function definition
Dimitri Papadopoulos [Mon, 21 Jun 2021 17:05:57 +0000 (19:05 +0200)]
Fix open brace '{' following function definition

Error reported by checkpatch.pl.

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix bad function definition
Dimitri Papadopoulos [Wed, 16 Jun 2021 12:01:50 +0000 (14:01 +0200)]
Fix bad function definition

Warnings by checkpatch.pl.
I have learned something today:
https://eklitzke.org/c-functions-without-arguments

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix suspect code indent
Dimitri Papadopoulos [Wed, 16 Jun 2021 11:27:25 +0000 (13:27 +0200)]
Fix suspect code indent

Warnings by checkpatch.pl.
I have fixed actual errors and left actual conscious decisions.

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix URL of repository of vpnc-script
Dimitri Papadopoulos [Tue, 29 Jun 2021 08:29:07 +0000 (10:29 +0200)]
Fix URL of repository of vpnc-script

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoUpdate documentation for the --authenticate option
Daniel Lenski [Thu, 24 Jun 2021 06:19:12 +0000 (23:19 -0700)]
Update documentation for the --authenticate option

Mention the CONNECT_URL and RESOLVE options, and how to use them to invoke
the connection phase in the maximally-robust way (which should work for all
protocols, and all possible proxies).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFix typo and clarify openconnect_get_connect_url comment slightly
Daniel Lenski [Thu, 24 Jun 2021 06:21:34 +0000 (23:21 -0700)]
Fix typo and clarify openconnect_get_connect_url comment slightly

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoReuse packets
David Woodhouse [Mon, 28 Jun 2021 13:44:51 +0000 (14:44 +0100)]
Reuse packets

I see malloc/free showing up at ~5% of perf traces, and it's entirely
pointless when we could be reusing packets.

This trick isn't *perfect* and there's potential for a pathological
case where all the packets on the free_queue are too small to be
reused but we never get rid of them anyway — but rounding up to 2KiB
should mean that never happens in practice, and the alignment we get
from that rounding probably doesn't hurt performance anyway.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd alloc_pkt() and free_pkt() helpers
David Woodhouse [Mon, 28 Jun 2021 11:54:53 +0000 (12:54 +0100)]
Add alloc_pkt() and free_pkt() helpers

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoStop polling cmd_fd while busy
David Woodhouse [Thu, 24 Jun 2021 15:54:00 +0000 (16:54 +0100)]
Stop polling cmd_fd while busy

We have an explicit select() call on the cmd_fd even when we're busy
shovelling packets and never hit the main select() in the mainloop.
This is *just* to ensure that we react to a cancel command quickly.

In the *common* case that we're running in openconnect(8), there's no
need for that since the *only* thing that will write to the cmd_fd is
openconnect itself, and *that* can set a flag in memory to tell us to
look.

So implement that optimisation — don't check it each time around the
mainloop unless the vpninfo->need_poll_cmd_fd flag is set. That flag
is set whenever we have written to cmd_fd and there's something to be
read. And cleared by poll_cmd_fd() when it runs and finds nothing there.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoMerge branch 'lzo' of gitlab.com:DimitriPapadopoulos/openconnect
David Woodhouse [Mon, 28 Jun 2021 15:44:24 +0000 (16:44 +0100)]
Merge branch 'lzo' of gitlab.com:DimitriPapadopoulos/openconnect

3 years agoMerge branch 'yubi' of gitlab.com:DimitriPapadopoulos/openconnect
David Woodhouse [Mon, 28 Jun 2021 15:39:17 +0000 (16:39 +0100)]
Merge branch 'yubi' of gitlab.com:DimitriPapadopoulos/openconnect

3 years agoMerge branch 'include' of gitlab.com:DimitriPapadopoulos/openconnect
David Woodhouse [Mon, 28 Jun 2021 15:39:06 +0000 (16:39 +0100)]
Merge branch 'include' of gitlab.com:DimitriPapadopoulos/openconnect

3 years agoMerge branch 'trailing_spaces' into 'master'
Dimitri Papadopoulos Orfanos [Mon, 28 Jun 2021 14:59:31 +0000 (14:59 +0000)]
Merge branch 'trailing_spaces' into 'master'

Get rid of trailing spaces

See merge request openconnect/openconnect!217

3 years agoLatest version of lzo.c
Dimitri Papadopoulos [Sun, 27 Jun 2021 07:44:42 +0000 (09:44 +0200)]
Latest version of lzo.c

We have pulled commit 004b582 from 14 May 2016.

Tests have been moved to a different file, so the file is smaller.
I have kept local changes, except the removal of INT_MAX -1000.

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFurther fix Yubikey/Android PBKDF2 bug URL
Dimitri Papadopoulos [Mon, 28 Jun 2021 12:45:36 +0000 (14:45 +0200)]
Further fix Yubikey/Android PBKDF2 bug URL

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoRemove duplicate includes
Dimitri Papadopoulos [Sun, 27 Jun 2021 09:10:11 +0000 (11:10 +0200)]
Remove duplicate includes

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoGet rid of trailing spaces
Dimitri Papadopoulos [Mon, 21 Jun 2021 17:34:55 +0000 (19:34 +0200)]
Get rid of trailing spaces

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'm4' into 'master'
David Woodhouse [Mon, 28 Jun 2021 10:09:11 +0000 (10:09 +0000)]
Merge branch 'm4' into 'master'

Update m4 files

See merge request openconnect/openconnect!225

3 years agoMerge branch 'assert' into 'master'
David Woodhouse [Mon, 28 Jun 2021 10:04:56 +0000 (10:04 +0000)]
Merge branch 'assert' into 'master'

Remove assert

See merge request openconnect/openconnect!223

3 years agoFix Yubikey/Android PBKDF2 bug URLs
David Woodhouse [Mon, 28 Jun 2021 08:30:29 +0000 (09:30 +0100)]
Fix Yubikey/Android PBKDF2 bug URLs

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoMerge branch 'https' into 'master'
Daniel Lenski [Mon, 28 Jun 2021 00:23:35 +0000 (00:23 +0000)]
Merge branch 'https' into 'master'

http:// -> https://

See merge request openconnect/openconnect!211

3 years agoUpdate m4 files
Dimitri Papadopoulos [Sun, 27 Jun 2021 12:39:07 +0000 (14:39 +0200)]
Update m4 files

m4/ax_check_vscript.m4
  the latest version from the Autoconf Archive

m4/iconv.m4
  the latest version from gnulib still compatible with autoconf 2.62

m4/lib-ld.m4
m4/lib-link.m4
m4/lib-prefix.m4
  the latest versions from gnulib

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agohttp:// -> https://
Dimitri Papadopoulos [Wed, 16 Jun 2021 10:38:35 +0000 (12:38 +0200)]
http:// -> https://

I have left out:
- sites that have not moved to HTTPS
- URLs found in XML and SVG files

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoRemove assert
Dimitri Papadopoulos [Sun, 27 Jun 2021 08:45:36 +0000 (10:45 +0200)]
Remove assert

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoUpdate translations from GNOME
David Woodhouse [Sun, 27 Jun 2021 16:05:04 +0000 (17:05 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoMerge branch 'recognise' into 'master'
David Woodhouse [Sun, 27 Jun 2021 14:21:50 +0000 (14:21 +0000)]
Merge branch 'recognise' into 'master'

ise → ize

Closes #268

See merge request openconnect/openconnect!221

3 years agoMerge branch 'server' into 'master'
David Woodhouse [Sun, 27 Jun 2021 14:15:14 +0000 (14:15 +0000)]
Merge branch 'server' into 'master'

Add option to read server name from config file

Closes #261 and #171

See merge request openconnect/openconnect!218

3 years agoNew option to define server name in config file
Dimitri Papadopoulos [Wed, 23 Jun 2021 09:17:18 +0000 (11:17 +0200)]
New option to define server name in config file

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoise → ize
Dimitri Papadopoulos [Fri, 25 Jun 2021 08:26:05 +0000 (10:26 +0200)]
ise → ize

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoAssume that a 'portal-*cookie' will allow us to bypass gateway SAML
Daniel Lenski [Fri, 28 May 2021 19:42:57 +0000 (12:42 -0700)]
Assume that a 'portal-*cookie' will allow us to bypass gateway SAML

For many GlobalProtect VPNs with SAML, the 'portal-userauthcookie' appears
to be *the* mechanism by which gateway authentication can be bypassed once
portal authentication is complete.

Unfortunately, there are exceptions which will require a more complex
resolution involved a re-entrant SAML flow
(https://gitlab.com/openconnect/openconnect/-/issues/147#note_587163143),
but this patch will at least not make them worse.

This can work in many cases…

- When the user's password is only usable one time (already working as of 008aefd7),
- When the portal requires SAML but the gateway doesn't (already working in 008aefd7),
- When the gateway requires SAML even though the portal doesn't (fixed here)

Additionally, this patch adds tests (tests/{fake-gp-server.py,gp-auth-and-config}) of
OpenConnect's ability to complete the following SAML flows:

- (SAML to portal after acquiring prelogin-cookie externally) → (complete gateway login
  using portal-userauthcookie)
- (SAML to gateway after acquiring prelogin-cookie externally)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMore complete comment about issues with proxies in connection phase
Daniel Lenski [Thu, 24 Jun 2021 06:16:16 +0000 (23:16 -0700)]
More complete comment about issues with proxies in connection phase

The comment for openconnect_get_connect_url (added in
https://gitlab.com/openconnect/openconnect/-/commit/ec6c0caed28ebf4f60984a49ce3122196f9c87fa)
should mention the possibility that a proxy requires the correct hostname at
the TLS layer (via Server Name Indication, SNI) as well at the HTTP layer
(via 'Host' header), in order to correctly forward it to the VPN server.

See https://gitlab.gnome.org/GNOME/NetworkManager-openconnect/-/issues/46
for a case where the 'Host' header was apparently required.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFortinet requires us to check for an HTTP error response only over TLS
Daniel Lenski [Thu, 17 Jun 2021 20:23:18 +0000 (13:23 -0700)]
Fortinet requires us to check for an HTTP error response only over TLS

If the Fortinet PPP connection request *succeeds* over TLS, there is no HTTP
response before we start exchanging PPP packets.  If it *fails*, there is an
HTTP response.

If the Fortinet PPP connection request is over DTLS, a 'svrhello' response
is expected regardless of whether it succeeded or failed. This is handled
by fortinet_dtls_catch_svrhello()

Let's only check for that HTTP response in Fortinet if we're definitely
connecting over TLS.  The "proceeding to tunnel stage" test in
'fortinet-auth-config-tests' verifies the correctness of the HTTP response
parsing behavior.

Fortinet connection response matrix ("Don't blame me, I didn't design this."):

           \ TRANSPORT
    STATUS  \             TLS               DTLS
             +            ---------------   -------------------
    Success  |            immediate → PPP   SVRHELLO 'ok' → PPP
    Failure  |            HTTP response     SVRHELLO 'fail'

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoCleanup fortinet-auth-config
Daniel Lenski [Thu, 17 Jun 2021 20:38:09 +0000 (13:38 -0700)]
Cleanup fortinet-auth-config

Fix a couple bits  which generate extra noise in the logs (left behind from
testing https://gitlab.com/openconnect/openconnect/-/merge_requests/209).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoPPP: Replace no_terminate_on_pause flag with terminate_on_pause flag
Daniel Lenski [Thu, 17 Jun 2021 20:14:32 +0000 (13:14 -0700)]
PPP: Replace no_terminate_on_pause flag with terminate_on_pause flag

We know of two real-world PPP-based VPNs that require us *not* to TERMINATE
at the PPP layer if we will want to subsequently resume a connection.  We
don't know of any real-world PPP-based VPNs that *do* want us to TERMINATE
at the PPP layer in this case; in fact, any server that *requires* this
would be unable to resume inadvertently dropped connections.

Replace the no_terminate_on_pause flag with a terminate_on_pause flag, in
order to reduce boilerplate and use the more plausible behavior as the
default.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFollow disable_ipv6 for Pulse and Fortinet
Daniel Lenski [Thu, 17 Jun 2021 17:25:15 +0000 (10:25 -0700)]
Follow disable_ipv6 for Pulse and Fortinet

As with other protocols (AnyConnect, F5, GP), the behavior of 'disable_ipv6'
for these protocols is relatively "shallow": if set, it will cause
OpenConnect to ignore any IPv6 address or netmask sent by the server, but
will *not* ignore IPv6 split-{in,ex}cludes or IPv6 addresses of DNS servers.

More thorough IPv6-ignoring could be handled by the vpnc-script, or cleaned
up as part of a future change to simplify IP configuration and routing
across protocols.

(The lack of support for --disable-ipv6 in Pulse was noted in
https://gitlab.com/openconnect/openconnect/-/issues/254.)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoWe can admit that the FTP site exists too.
David Woodhouse [Wed, 16 Jun 2021 23:03:29 +0000 (00:03 +0100)]
We can admit that the FTP site exists too.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoDocs should link to Gitlab as the main repository for vpnc-script and vpnc-script...
Daniel Lenski [Wed, 16 Jun 2021 19:08:14 +0000 (19:08 +0000)]
Docs should link to Gitlab as the main repository for vpnc-script and vpnc-script-win.js

All of the recent improvements/development of these scripts have taken
place on GitLab.

I believe these were reverted inadvertently in
https://gitlab.com/openconnect/openconnect/-/commit/363fd538b08b39f07cc09282608f43f1faa29a4f

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMark juniper-sso-auth test as using LD_PRELOAD
Daniel Lenski [Sat, 29 May 2021 17:42:19 +0000 (10:42 -0700)]
Mark juniper-sso-auth test as using LD_PRELOAD

This will allow us to correctly detect it as broken-under-ASAN

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoUpdate changelog
Daniel Lenski [Thu, 20 May 2021 14:43:13 +0000 (07:43 -0700)]
Update changelog

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAdd tests of using portal-userauthcookie to continue through gateway
Daniel Lenski [Thu, 20 May 2021 01:35:55 +0000 (18:35 -0700)]
Add tests of using portal-userauthcookie to continue through gateway

This test sets up fake-gp-server.py to require a one-time password on the
portal *and* on the gateway, and to set 'portal-userauthcookie' after
successful login to the gateway.  For OpenConnect to successfully login
within prompting for a second password, the 'portal-userauthcookie' value
from the portal must be forwarded to the gateway login request.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoReceiving a portal-*cookie should allow us to automatically retry the login on the...
Daniel Lenski [Fri, 22 May 2020 00:56:19 +0000 (17:56 -0700)]
Receiving a portal-*cookie should allow us to automatically retry the login on the gateway

This applies EVEN IF the the final portal login form was a challenge form, or a SAML
form (that is, if ctx->alt_secret was set).

It appears that the whole point of these `portal-*cookie`s is to allow us to automatically
continue logging in through the gateway.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoDon't save `portal-*cookie` values if they're "empty"
Daniel Lenski [Fri, 22 May 2020 01:01:16 +0000 (18:01 -0700)]
Don't save `portal-*cookie` values if they're "empty"

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoPass the `portal-*cookie` values received in the portal config to the gateway login
Kevin Yue [Wed, 13 May 2020 06:35:42 +0000 (14:35 +0800)]
Pass the `portal-*cookie` values received in the portal config to the gateway login

These "cookies" appear to be the mechanism by which GlobalProtect clients
can login to the portal and then automatically login to gateway *even if*
the credentials used on the portal are not reusable:

1. Because the credentials used on the portal include a one-time password.
2. Because the credentials used on the portal resulted from SAML login.
   (ctx->alt_secret, which leads to a SAML nonce value that can only be
   used once).

The logs provided by users (see
https://gitlab.com/openconnect/openconnect/-/issues/147#note_578888250 and
https://gitlab.com/openconnect/openconnect/-/issues/147#note_580406042)
allowed me to answer one of the key unanswered questions (see
https://gitlab.com/openconnect/openconnect/-/merge_requests/109#note_341959833):

> If we do have a `portal_userauthcookie` and/or
> `portal_prelogonuserauthcookie`, should we omit the password from form
> submitted to the gateway?  Or do we have to leave it in?

The answer is that it doesn't appear to matter: real servers appear to
ignore the `passwd` field if the `portal-*cookie` field is correctly set.

Signed-off-by: Kevin Yue <yuezk001@gmail.com>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAdd +SIGN-ALL to GnuTLS DTLS ciphersuite configs
David Woodhouse [Tue, 15 Jun 2021 13:33:35 +0000 (14:33 +0100)]
Add +SIGN-ALL to GnuTLS DTLS ciphersuite configs

At least for AES256-SHA et al in DTLSv1.2, we needed to explicitly add
+SIGN-RSA-SHA1. Half the ciphersuites already had +SIGN-ALL anyway, so
make them consistent.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoOffer OpenConnect-specific DTLSv1.2 AEAD suites with OpenSSL again
David Woodhouse [Tue, 15 Jun 2021 13:27:38 +0000 (14:27 +0100)]
Offer OpenConnect-specific DTLSv1.2 AEAD suites with OpenSSL again

These got dropped when we built the list from what's supported instead
of hard-coding it.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoSupport non-AEAD ciphersuites in DTLSv1.2 with GnuTLS
David Woodhouse [Tue, 15 Jun 2021 12:02:49 +0000 (13:02 +0100)]
Support non-AEAD ciphersuites in DTLSv1.2 with GnuTLS

We have encountered a Cisco server in the wild which appears only to
support the legacy ciphersuites. And since we offer a set of DTLSv1.2
ciphers it doesn't fall back to accepting the DTLSv1.0 offer; we end
up with no DTLS at all.

This should fix #249.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agohttp: Allow passing header_cb to do_https_request
Andreas Gnau [Sat, 29 May 2021 11:58:50 +0000 (13:58 +0200)]
http: Allow passing header_cb to do_https_request

Enable passing a header callback to do_https_request in order to be able
to process response headers.

Signed-off-by: Andreas Gnau <rondom@rondom.de>
3 years agoUpdate translations from GNOME
David Woodhouse [Tue, 15 Jun 2021 09:06:29 +0000 (10:06 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoSwitch to https for all URLs
David Woodhouse [Tue, 15 Jun 2021 09:00:44 +0000 (10:00 +0100)]
Switch to https for all URLs

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoUse https://www.infradead.org/openconnect/download/ URLs
David Woodhouse [Tue, 15 Jun 2021 08:49:22 +0000 (09:49 +0100)]
Use https://www.infradead.org/openconnect/download/ URLs

FTP is getting harder to access these days.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoRemove reference to --allow-obsolete-crypto bypassing policies
David Woodhouse [Tue, 15 Jun 2021 08:11:43 +0000 (09:11 +0100)]
Remove reference to --allow-obsolete-crypto bypassing policies

We do that unconditionally now.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd changelog for system policy disable
David Woodhouse [Sat, 12 Jun 2021 09:42:40 +0000 (10:42 +0100)]
Add changelog for system policy disable

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoMark obsolete-server-crypto test as XFAIL in Fedora/GnuTLS/* CI
Daniel Lenski [Sat, 29 May 2021 17:39:57 +0000 (10:39 -0700)]
Mark obsolete-server-crypto test as XFAIL in Fedora/GnuTLS/* CI

The system-wide minimum crypto policy on Fedora prevents us from enabling
3DES and RC4 ciphers via GnuTLS priority strings. We have unconditionally
disabled it in OpenConnect for now in commit 7e862f2f03 but the
obsolete-server-crypto test is *still* failing, with ocserv reporting
'GnuTLS error (at worker-vpn.c:861): No supported cipher suites have
been found.'

Just mark obsolete-server-crypto test as XFAIL for these builds.  It's
the most accurate description of the state of those tests: these
environments do not provide OpenConnect with the capabilities to
reliably enable obsolete/insecure crypto algorithms in a self-contained
way.

See https://bugzilla.redhat.com/show_bug.cgi?id=1960763 for ongoing
discussions about how to come up with a more reliable, testable, and
maintainable mechanism for OpenConnect to enable these algorithms without
compromising the system-wide minimum crypto policy.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoUnconditionally bypass system crypto policy
David Woodhouse [Sat, 12 Jun 2021 07:50:09 +0000 (08:50 +0100)]
Unconditionally bypass system crypto policy

This makes me extremely sad, but they rolled it out with *no* way to
selectively allow the user to say "connect anyway", as we've always had
for "invalid" certificates, etc.

It's just unworkable and incomplete as currently implemented in the
distributions, so we have no choice except to bypass it and wait for
it to be fixed.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoDisable ASAN tests for now
David Woodhouse [Sat, 12 Jun 2021 07:39:16 +0000 (08:39 +0100)]
Disable ASAN tests for now

We have no idea why they're broken but only in CI.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoRevert "with --allow-insecure-crypto, additionally attempt to disable insecure system...
David Woodhouse [Sat, 12 Jun 2021 07:33:10 +0000 (08:33 +0100)]
Revert "with --allow-insecure-crypto, additionally attempt to disable insecure systemwide minimum crypto settings"

This reverts commit 4e07eecaf04a48c3253a5dfd69d817673194e154.

3 years agoMerge branch 'chmod-x_tun-win32.c' of gitlab.com:DimitriPapadopoulos/openconnect
David Woodhouse [Sat, 12 Jun 2021 07:30:15 +0000 (08:30 +0100)]
Merge branch 'chmod-x_tun-win32.c' of gitlab.com:DimitriPapadopoulos/openconnect

3 years agoMerge branch 'obsolete_http_configuration' of gitlab.com:DimitriPapadopoulos/openconnect
David Woodhouse [Fri, 11 Jun 2021 20:46:47 +0000 (21:46 +0100)]
Merge branch 'obsolete_http_configuration' of gitlab.com:DimitriPapadopoulos/openconnect

3 years agoFix static-analyzer CI builds
David Woodhouse [Wed, 9 Jun 2021 13:53:42 +0000 (14:53 +0100)]
Fix static-analyzer CI builds

The image changed its name.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agochmod -x
Dimitri Papadopoulos [Fri, 11 Jun 2021 18:45:00 +0000 (20:45 +0200)]
chmod -x

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoBetter document obsolete code and why we keep it
Dimitri Papadopoulos [Fri, 11 Jun 2021 18:22:10 +0000 (20:22 +0200)]
Better document obsolete code and why we keep it

This code has been disabled by default in openfortivpn:
https://github.com/adrienverge/openfortivpn/pull/902

We keep it in openconnect for now, commenetd out, for debugging purposes.

Signed-off-by: Dimitri Papadopoulos <3350651+DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'clarify_Certificate_Validation_Failure_error' of gitlab.com:openconnect...
David Woodhouse [Fri, 11 Jun 2021 08:42:59 +0000 (09:42 +0100)]
Merge branch 'clarify_Certificate_Validation_Failure_error' of gitlab.com:openconnect/openconnect

3 years agoFix Fortinet realm name extraction
Daniel Lenski [Thu, 10 Jun 2021 22:45:08 +0000 (15:45 -0700)]
Fix Fortinet realm name extraction

1. We were inadvertently capturing 6 characters following the 'realm'
   parameter in the query string (e.g.  '&lang=').  Fix and include extra
   parameters in tests to verify.
2. Add another comment about how the 'realm' field is saved in URL-escaped
   form, and test to verify.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFix out-of-tree builds with ASAN
David Woodhouse [Wed, 9 Jun 2021 13:50:12 +0000 (14:50 +0100)]
Fix out-of-tree builds with ASAN

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoBump Android dependencies
David Woodhouse [Wed, 9 Jun 2021 12:59:35 +0000 (13:59 +0100)]
Bump Android dependencies

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd Android CI builds
David Woodhouse [Wed, 9 Jun 2021 10:55:28 +0000 (11:55 +0100)]
Add Android CI builds

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoFix PPP packets split across TLS records
Daniel Lenski [Mon, 7 Jun 2021 22:46:23 +0000 (15:46 -0700)]
Fix PPP packets split across TLS records

This replicates the behavior of oncp_record_read(): if a (D)TLS record
ends with an incomplete PPP packet, we save the read-so-far length as
vpninfo->partial_rec_size, and continue reading at that point on the
next iteration.

This poorly-layered packetisation behavior was observed on Fortinet and
may exist for other encapsulations as well. So we cope with it for
PPP_ENCAP_F5 because it's trivial, but not yet PPP_ENCAP_F5_HDLC which
would be harder; we'll wait until we actually see it there before
delving into that complexity.

This works as expected to prevent loss of synchronization to the
encapsulation header.  Here's an example showing receipt of incomplete
Fortinet/PPP packets, during a high rate of incoming packets generated with
'iperf3 -c $IP_ON_REMOTE_NETWORK -R', followed by recovery on subsequent
mainloop iterations:

    Received IPv4 data packet of 1183 bytes over TLS
    Fortinet packet is incomplete (837 bytes on wire but header payload_len is 1185). Waiting for more.
    Packet contains 539 bytes after payload. Assuming concatenated packet.
    Received IPv4 data packet of 1183 bytes over TLS
    Fortinet packet is incomplete (539 bytes on wire but header payload_len is 1185). Waiting for more.
    No work to do; sleeping for 10000 ms...
    No work to do; sleeping for 10000 ms...
    No work to do; sleeping for 10000 ms...
    No work to do; sleeping for 10000 ms...
    Packet contains 13101 bytes after payload. Assuming concatenated packet.
    Received IPv4 data packet of 1183 bytes over TLS
    Packet contains 11910 bytes after payload. Assuming concatenated packet.
    Received IPv4 data packet of 1183 bytes over TLS
    Packet contains 10719 bytes after payload. Assuming concatenated packet.
    Received IPv4 data packet of 1183 bytes over TLS
    Packet contains 9528 bytes after payload. Assuming concatenated packet.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoRename oncp_rec_size → partial_rec_size
Daniel Lenski [Tue, 8 Jun 2021 18:13:39 +0000 (11:13 -0700)]
Rename oncp_rec_size → partial_rec_size

This variable is used to track the size of partially-received tunnel packets
across mainloop invocations.

It was intially used by the oNCP protocol, where tunneled packets can be
split across TLS records.  We're now going to use it to deal with an
extremely similar mis-layering of packetisation for PPP-based protocols
as well.

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

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoFix handling of concatenated PPP data packets
Daniel Lenski [Mon, 7 Jun 2021 22:14:57 +0000 (15:14 -0700)]
Fix handling of concatenated PPP data packets

This 'continue' prevented us from ever actually processing a concatenated
packet if the first one was a *data* packet.  Dan only tested this for
concatenation of config packets in the early stages of the connection.  Bad
Dan.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoIncrease SO_SNDBUF on UDP socket
David Woodhouse [Tue, 8 Jun 2021 19:34:45 +0000 (20:34 +0100)]
Increase SO_SNDBUF on UDP socket

In commit 3444f811ae ("Set SO_SNDBUF on DTLS socket and handle -EAGAIN
on it") in 2013 I cut the socket wmem to just 2 packets in size, to fix
bufferbloat issues when handling VoIP streams simultaneously with bulk
uploads.

In #250 we discovered that this is a problem for high-bandwidth setups
because we aren't actually keeping the send buffers full. Even though
there's only ~100µs of latency between getting -EAGAIN on the UDP
socket, and finally sending the packet successfully...

20:03:38.803525 sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\27\376\375\0\1\0\0\0\2m\226\5Q\0\1\0\0\0\2m\226\177\202#\344>-\315H6N\233"..., iov_len=1374}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
20:03:38.803556 select(4, [3], NULL, NULL, {tv_sec=0, tv_usec=0}) = 0 (Timeout)
20:03:38.803585 select(7, [3 5 6], [5], [5], {tv_sec=6, tv_usec=0}) = 1 (in [6], left {tv_sec=5, tv_usec=999998})
20:03:38.803616 sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\27\376\375\0\1\0\0\0\2m\226\5Q\0\1\0\0\0\2m\226\177\202#\344>-\315H6N\233"..., iov_len=1374}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 1374

... that's 100µs when the physical network device actually has nothing to
send. And it's happening over and over again as the UDP socket buffers
fill and then we poll for them to be sufficiently empty again.

This is exacerbated by the fact that ip_info.mtu is actually zero at
this point for PPP protocols — but only slightly because 2*1500 isn't
actually much more than the minimum value we get when we ask for zero
anyway.

It also doesn't help that the kernel deliberately doesn't wake a waiter
until they can make "significant" progress and the buffers are down to
*half* the sndbuf value (see sock_def_write_space() in net/core/sock.c).

Testing with 'iperf3 -u -b 900M' on my home network with 1Gb/s network
between client and (Fortinet) server, I find I have to have to use a
value of around 20000 (doubled to 40000) in order to avoid seeing drops
on the *tun* interface because we aren't moving packets fast enough.

We need to find a decent balance between high-bandwidth and bufferbloat,
so let's try the following: First "assume" 1500 for the MTU if it isn't
actually set, and then multiply by the configured queue len which
defaults to 10. That ought to be a reasonable compromise for bandwidth
vs. bufferbloat for the general case, *and* allows users to tweak it.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd setCookie JNI method to LibOpenConnect.java
Antonino Orlando [Thu, 3 Jun 2021 21:26:11 +0000 (23:26 +0200)]
Add setCookie JNI method to LibOpenConnect.java

DL: This was added to jni.c in 5b3d3a86, but was inadvertently omitted from
the .java side.

Signed-off-by: Antonino Orlando <orlando.antonino@gmail.com>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoClarify 'Certificate Validation Failure' error from Cisco servers
Daniel Lenski [Mon, 31 May 2021 22:56:30 +0000 (15:56 -0700)]
Clarify 'Certificate Validation Failure' error from Cisco servers

Cisco servers send this ambiguous error string when the CLIENT certificate
is absent or incorrect.  We rewrite it to make this clearer, while
preserving the original error as a substring. See #160.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFix MinGW CI build to use their own docker images, now we have them.
David Woodhouse [Sat, 29 May 2021 10:03:55 +0000 (11:03 +0100)]
Fix MinGW CI build to use their own docker images, now we have them.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoPrint an error message if dtls_addr is NULL in dtls_setup()
Daniel Lenski [Fri, 28 May 2021 19:50:51 +0000 (12:50 -0700)]
Print an error message if dtls_addr is NULL in dtls_setup()

This should reduce confusion and help debugging in situations like #242,
where a Cisco server apparently does not return any 'X-DTLS-*' headers upon
connection.

We were printing this message in connect_dtls_socket(), but since
dtls_setup() gets called — and fails — *first* in that case, the message
never got printed.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoBugfix GlobalProtect ESP magic pings over Legacy IP
Daniel Lenski [Thu, 20 May 2021 22:53:25 +0000 (15:53 -0700)]
Bugfix GlobalProtect ESP magic pings over Legacy IP

GlobalProtect IPv6 support was added in
https://gitlab.com/openconnect/openconnect/-/merge_requests/188, and
specifically support for initiating an ESP connection via ICMPv6 "magic
pings" in specifically 5b98b62883216cf9306f06c6b3c9dde81bcfe789.

Getting the ICMPv6 packets to have correct checksums was quite tricky (see
commit notes) and the commit was revised several times.

Somehow we managed to remove the pre-existing code to compute the checksum
correctly in the case of ICMPv4 "magic pings", leaving behind an ICMPv4
checksum that's always zero (and thus rejected by the server, and never
correctly initiates a connection).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFix store_le16/store_le32 harder
David Woodhouse [Thu, 20 May 2021 19:05:15 +0000 (20:05 +0100)]
Fix store_le16/store_le32 harder

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoUse C99 initializer instead of memset.
Tom Carroll [Mon, 17 May 2021 05:58:24 +0000 (22:58 -0700)]
Use C99 initializer instead of memset.

Strictly speaking, using memset() here violates strict aliasing rules,
and it would be entirely permissible for an assert() like this example
to *fail*:

struct gtls_cert_info gci;

memset(&gci, 0, sizeof gci);
assert(gci.pkey == NULL);

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
3 years agoAdd more buf_append_base64() tests... and fix it.
David Woodhouse [Wed, 19 May 2021 09:45:39 +0000 (10:45 +0100)]
Add more buf_append_base64() tests... and fix it.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoFix first line length in buf_append_base64()
David Woodhouse [Wed, 19 May 2021 08:32:41 +0000 (09:32 +0100)]
Fix first line length in buf_append_base64()

We need to add four (for the characters we're about to append) *after*
checking against line_len and resetting ll to zero. Otherwise the first
line thinks it starts at 4 while the others start at 0.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoValidate line_len argument to buf_append_base64() too
David Woodhouse [Wed, 19 May 2021 08:31:31 +0000 (09:31 +0100)]
Validate line_len argument to buf_append_base64() too

Based on a patch by Tom Carroll <incentivedesign@gmail.com>

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoDon't leak memory in buftest
David Woodhouse [Tue, 18 May 2021 18:18:42 +0000 (19:18 +0100)]
Don't leak memory in buftest

It makes ASAN unhappy

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoUpdate translations from GNOME
David Woodhouse [Tue, 18 May 2021 17:57:43 +0000 (18:57 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoFix buftest to build on Windows
David Woodhouse [Tue, 18 May 2021 17:56:49 +0000 (18:56 +0100)]
Fix buftest to build on Windows

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoFix fallback/big-endian store_le16() and store_le32()
David Woodhouse [Tue, 18 May 2021 17:55:12 +0000 (18:55 +0100)]
Fix fallback/big-endian store_le16() and store_le32()

These were swapped.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoLimit oc_text_buf to 16MiB, start adding test cases
David Woodhouse [Tue, 18 May 2021 17:27:58 +0000 (18:27 +0100)]
Limit oc_text_buf to 16MiB, start adding test cases

We really ought to unit test this a lot harder. This is a start...

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoMove oc_text_buf functions out to textbuf.c for easier unit testing
David Woodhouse [Tue, 18 May 2021 08:53:06 +0000 (09:53 +0100)]
Move oc_text_buf functions out to textbuf.c for easier unit testing

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoCorrect calculation of base64 encode buffer length.
Tom Carroll [Tue, 18 May 2021 06:58:23 +0000 (23:58 -0700)]
Correct calculation of base64 encode buffer length.

In the previous formulation, it would first multiple then divide. It would then
promote to unsigned int. The formula would overflow for large len. For example,
needed = 2 when len == INT_MAX. In the revised formulation, it is promoted,
divided, then multiplied. The revised calculation avoids the overflow and
computes needed correctly over len in {0, 1, ..., INT_MAX}.  For len == INT_MAX,
needed is correctly computed as 2863311533.

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
3 years agoCheck gnutls_pubkey_init return code.
Tom Carroll [Mon, 17 May 2021 17:08:29 +0000 (10:08 -0700)]
Check gnutls_pubkey_init return code.

gnutls_pubkey_import_x509 doesn't verify if pubkey == NULL.

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
3 years agoAdd line length argument to buf_append_base64()
David Woodhouse [Mon, 17 May 2021 11:26:54 +0000 (12:26 +0100)]
Add line length argument to buf_append_base64()

The multicert support will want to use this.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agognutls.c:943:21: warning: comparison of integer expressions of different signedness...
Tom Carroll [Mon, 17 May 2021 05:56:57 +0000 (22:56 -0700)]
gnutls.c:943:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]

The gci->nr_certs field is an unsigned int. Use that as the loop variable
for freeing them too. And we don't actually need the if (gci->certs)
condition here either because ->nr_certs won't be non-zero in that case
anyway.

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>