]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
3 years agoReplace comma with space when multiple search domains specified.
Nick Krylov [Thu, 14 Apr 2022 17:02:11 +0000 (20:02 +0300)]
Replace comma with space when multiple search domains specified.

3 years agoSilence warning.
Nick Krylov [Thu, 14 Oct 2021 04:44:55 +0000 (07:44 +0300)]
Silence warning.

3 years agoFix MinGW build.
Nick Krylov [Thu, 14 Oct 2021 04:43:14 +0000 (07:43 +0300)]
Fix MinGW build.

3 years agoAdd more feature support information.
Nick Krylov [Sat, 10 Jul 2021 12:20:39 +0000 (15:20 +0300)]
Add more feature support information.

3 years agoMention CheckPoint on the first page.
Nick Krylov [Sat, 10 Jul 2021 12:20:14 +0000 (15:20 +0300)]
Mention CheckPoint on the first page.

3 years agoChange user-visible protocol name.
Nick Krylov [Sat, 10 Jul 2021 11:48:24 +0000 (14:48 +0300)]
Change user-visible protocol name.

3 years agoPrevent old packet reuse on error.
Nick Krylov [Tue, 6 Jul 2021 07:08:49 +0000 (10:08 +0300)]
Prevent old packet reuse on error.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoDo not start tunnel twice on reconnect.
Nick Krylov [Tue, 6 Jul 2021 07:07:33 +0000 (10:07 +0300)]
Do not start tunnel twice on reconnect.

ssl_reconnect calls cp_connect that does tunnel initialization.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoRemove leading slash.
Nick Krylov [Sun, 4 Jul 2021 05:37:35 +0000 (08:37 +0300)]
Remove leading slash.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoReopen already closed TLS connection.
Nick Krylov [Sun, 4 Jul 2021 05:36:36 +0000 (08:36 +0300)]
Reopen already closed TLS connection.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoMention CheckPoint in man too.
Nick Krylov [Sat, 3 Jul 2021 10:44:38 +0000 (13:44 +0300)]
Mention CheckPoint in man too.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoAdd basic CheckPoint VPN protocol page.
Nick Krylov [Sun, 20 Jun 2021 09:37:51 +0000 (12:37 +0300)]
Add basic CheckPoint VPN protocol page.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoSend disconnect on real logout only.
Nick Krylov [Sat, 3 Jul 2021 10:13:47 +0000 (13:13 +0300)]
Send disconnect on real logout only.

'disconnect' command invalidates cookie and we can't regenerate it
using already opened session.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoAdd extra safety check.
Nick Krylov [Sat, 3 Jul 2021 09:14:11 +0000 (12:14 +0300)]
Add extra safety check.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoFix inverted condition.
Nick Krylov [Sat, 3 Jul 2021 09:06:17 +0000 (12:06 +0300)]
Fix inverted condition.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoInitialize len field.
Nick Krylov [Sat, 3 Jul 2021 09:05:38 +0000 (12:05 +0300)]
Initialize len field.

This became necessary after switching to alloc_pkt, because letter does malloc, not calloc.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoAdd a hint to the warning message.
Nick Krylov [Wed, 30 Jun 2021 08:15:24 +0000 (11:15 +0300)]
Add a hint to the warning message.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoSend SNX disconnect packet via mainloop
Daniel Lenski [Tue, 29 Jun 2021 17:41:24 +0000 (10:41 -0700)]
Send SNX disconnect packet via mainloop

Uses 'vpninfo->delay_close = DELAY_CLOSE_IMMEDIATE_CALLBACK', like PPP
mainloop.

Also, rename snx_send_command → snx_queue_command to reflect its current
behavior.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoUse alloc_pkt/free_pkt for CheckPoint
Daniel Lenski [Tue, 29 Jun 2021 17:32:25 +0000 (10:32 -0700)]
Use alloc_pkt/free_pkt for CheckPoint

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge remote-tracking branch 'upstream/master' into cpvpn
Daniel Lenski [Tue, 29 Jun 2021 17:21:37 +0000 (10:21 -0700)]
Merge remote-tracking branch 'upstream/master' into cpvpn

3 years agoMake the CP SNX mainloop more like the structure of OpenConnect's battle-tested TLS...
Daniel Lenski [Mon, 28 Jun 2021 19:58:32 +0000 (12:58 -0700)]
Make the CP SNX mainloop more like the structure of OpenConnect's battle-tested TLS mainloop for other protocols

Also, use a statically-allocated 'keepalive' packet so we don't have to keep malloc'ing and free'ing it.

I didn't add any gotos yet but… they're coming.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoHandle repeated hello_reply (but leave warning behind)
Daniel Lenski [Mon, 28 Jun 2021 17:56:24 +0000 (10:56 -0700)]
Handle repeated hello_reply (but leave warning behind)

See discussion here: https://gitlab.com/openconnect/openconnect/-/merge_requests/207#note_612289607

Restarting the tunnel device if the server spontaneously changes the
client's IP address(es) doesn't currently fit within OpenConnect's security
model, though we may want/need to support it in the future.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
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 agoUpdate copyright notice.
Nick Krylov [Sun, 27 Jun 2021 07:58:51 +0000 (10:58 +0300)]
Update copyright notice.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoAllow tun setup as soon as hello_reply arrived.
Nick Krylov [Sun, 27 Jun 2021 07:54:13 +0000 (10:54 +0300)]
Allow tun setup as soon as hello_reply arrived.

Signed-off-by: Nick Krylov <krylovna@gmail.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 agoFix disconnect-instead-of-hello_reply
Daniel Lenski [Fri, 25 Jun 2021 20:11:55 +0000 (13:11 -0700)]
Fix disconnect-instead-of-hello_reply

handle_hello_reply() wouldn't actually get called unless the command packet
started with "(hello_reply". Move handling of "(disconnect" to
snx_handle_command() to fix this.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMatch 'braciness' of rest of OpenConnect code
Daniel Lenski [Fri, 25 Jun 2021 20:00:54 +0000 (13:00 -0700)]
Match 'braciness' of rest of OpenConnect code

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMatch indentation convention of rest of OpenConnect
Daniel Lenski [Fri, 25 Jun 2021 19:54:20 +0000 (12:54 -0700)]
Match indentation convention of rest of OpenConnect

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoRepeated hello_reply is likely an error
Daniel Lenski [Fri, 25 Jun 2021 19:47:44 +0000 (12:47 -0700)]
Repeated hello_reply is likely an error

1. Detect repeated hello_reply with ssl_times.last_rekey!=0, not
   !ip_info->addr (cf. 9f3e834551400080ef3778b757fb5643305c74dd)
2. No need to explicitly clear ip_info structure, now that CP is using
   install_vpn_opts (cf. 0477b7bbc774cec5771d87dc9ed9d7e879af6b62)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoWith delay_tunnel_reason, no longer need to shutdown/restart tun
Daniel Lenski [Fri, 25 Jun 2021 19:44:08 +0000 (12:44 -0700)]
With delay_tunnel_reason, no longer need to shutdown/restart tun

Signed-off-by: Daniel Lenski <dlenski@gmail.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 agoFix tunnel delay logic.
Nick Krylov [Thu, 24 Jun 2021 10:04:15 +0000 (13:04 +0300)]
Fix tunnel delay logic.

This check must be here otherwise delay may end before hello_reply is fully received.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoAvoid full tun restart on the initial hello_reply.
Nick Krylov [Thu, 24 Jun 2021 09:38:30 +0000 (12:38 +0300)]
Avoid full tun restart on the initial hello_reply.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoConsistently use OpenConnect-standard int return pattern.
Nick Krylov [Thu, 24 Jun 2021 09:38:09 +0000 (12:38 +0300)]
Consistently use OpenConnect-standard int return pattern.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoAdd a bunch of resource-related checks and fixes.
Nick Krylov [Thu, 24 Jun 2021 09:21:54 +0000 (12:21 +0300)]
Add a bunch of resource-related checks and fixes.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoSmall spell fix.
Nick Krylov [Thu, 24 Jun 2021 09:13:04 +0000 (12:13 +0300)]
Small spell fix.

Signed-off-by: Nick Krylov <krylovna@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 agoEnsure that hello_reply packet is the very first one received after client_hello...
Daniel Lenski [Wed, 23 Jun 2021 23:15:58 +0000 (16:15 -0700)]
Ensure that hello_reply packet is the very first one received after client_hello sent

Let's (ab)use ssl_times.last_rekey, by not setting it until we receive the hello_reply.

Control flow/exception-handling here will need some cleanup… very likely to include 'goto' 😁😈

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agofixup! Remove blocking send/receive in SNX mode.
Daniel Lenski [Wed, 23 Jun 2021 23:09:52 +0000 (16:09 -0700)]
fixup! Remove blocking send/receive in SNX mode.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAdd some comments on how/why enc_dec_ichr() works
Daniel Lenski [Tue, 22 Jun 2021 17:45:50 +0000 (10:45 -0700)]
Add some comments on how/why enc_dec_ichr() works

This function depends on some very specific properties of the constant 0x3531DEC1.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMove user credentials retrieval.
Nick Krylov [Tue, 22 Jun 2021 17:46:31 +0000 (20:46 +0300)]
Move user credentials retrieval.

We don't need them with certificate-based login. Avoid goto.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoSmall formatting fixes.
Nick Krylov [Tue, 22 Jun 2021 17:36:06 +0000 (20:36 +0300)]
Small formatting fixes.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoRemove blocking send/receive in SNX mode.
Nick Krylov [Tue, 22 Jun 2021 17:25:17 +0000 (20:25 +0300)]
Remove blocking send/receive in SNX mode.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoFix cpsnx struct pad field.
Nick Krylov [Tue, 22 Jun 2021 09:31:50 +0000 (12:31 +0300)]
Fix cpsnx struct pad field.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoUse strncmp, not strstr, when looking for a prefix
Daniel Lenski [Mon, 21 Jun 2021 23:58:07 +0000 (16:58 -0700)]
Use strncmp, not strstr, when looking for a prefix

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoEnsure that command packets are null-terminated
Daniel Lenski [Mon, 21 Jun 2021 23:57:07 +0000 (16:57 -0700)]
Ensure that command packets are null-terminated

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAdd pkt.cpsnx header type (rather than relying on having same header size as CSTP)
Daniel Lenski [Mon, 21 Jun 2021 23:15:58 +0000 (16:15 -0700)]
Add pkt.cpsnx header type (rather than relying on having same header size as CSTP)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoLeave original urlpath as-is if provided, but set to "/clients/" if not
Daniel Lenski [Mon, 21 Jun 2021 22:28:11 +0000 (15:28 -0700)]
Leave original urlpath as-is if provided, but set to "/clients/" if not

Many VPN protocols (e.g.  AnyConnect, Fortinet, oNCP, Pulse) use the
URL-path to select alternative realms/domains/groups for authentication.
Leave this possibility open for CP.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoIn-band disconnect command should be sent without blocking
Daniel Lenski [Mon, 21 Jun 2021 22:21:25 +0000 (15:21 -0700)]
In-band disconnect command should be sent without blocking

We're only going to try it once, and we'll want to reopen the connection to
logoff the session right after.  (cf.  PPP termination, cstp_bye)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoStore connect_with_certificate_url as urlpath and considerably simplify do_get_cookie
Daniel Lenski [Mon, 21 Jun 2021 22:01:56 +0000 (15:01 -0700)]
Store connect_with_certificate_url as urlpath and considerably simplify do_get_cookie

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoRemove unnecessary redirect-to-/ before tunnel connection
Daniel Lenski [Mon, 21 Jun 2021 21:43:39 +0000 (14:43 -0700)]
Remove unnecessary redirect-to-/ before tunnel connection

Starting with send_client_hello(), this is no longer an HTTP socket; it's
just a plain TLS socket.  The urlpath is no longer relevant/necessary.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoDon't hide_auth_data() if built with INSECURE_DEBUGGING
Daniel Lenski [Mon, 21 Jun 2021 21:00:53 +0000 (14:00 -0700)]
Don't hide_auth_data() if built with INSECURE_DEBUGGING

Run './configure --enable-insecure-debugging' to #define this flag. This will allow
us to see unfiltered data using the usual '--dump-http-traffic' mechanism.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoRemove last vestiges of {find,get,add,set}_option
Daniel Lenski [Mon, 21 Jun 2021 20:45:03 +0000 (13:45 -0700)]
Remove last vestiges of {find,get,add,set}_option

The presence or absence of the 'protocol_version' option was being used to
check whether we had already run do_ccc_client_hello().  As far as I can
tell, it should be good enough to simply call it in cp_obtain_cookie.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoSave slim_cookie:session_id as vpninfo->cookie (rather than constantly rebuilding...
Daniel Lenski [Mon, 21 Jun 2021 19:46:57 +0000 (12:46 -0700)]
Save slim_cookie:session_id as vpninfo->cookie (rather than constantly rebuilding it to/from cstp_options

In addition to eliminating unnecessary use of cstp_options for saving state,
this makes the code much simpler *and* it will be required for 'openconnect
--authenticate' to work correctly (necessary for front-ends like NM-oc as
well).

I also replaced cp_bye with a more OpenConnect-idiomatic version based on
{oncp,gpst,f5,fortinet}_bye:

1. Save and restore 'vpninfo->urlpath' directly (this pattern is kinda ugly,
   but it's the established one within the codebase).
2. Extract session_id directly from vpninfo->cookie; this is similar to the
   GP case, where we have values that we need save in the cookie because
   they're required for logout to succeed… and *only* for logout.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoSimply log, rather than save, server options whose values aren't clearly needed later
Daniel Lenski [Mon, 21 Jun 2021 19:14:36 +0000 (12:14 -0700)]
Simply log, rather than save, server options whose values aren't clearly needed later

Working on eliminating use of cstp_options to store a lot of state that doesn't really need to be saved.

NB: The standard value for 'connect_with_certificate_url' (based on 3 servers that I've tested)
is actually "/clients/cert/", with a trailing slash, not "/clients/cert".

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoReplace decode/encode with unscramble/buf_append_scrambled
Daniel Lenski [Mon, 21 Jun 2021 19:11:15 +0000 (12:11 -0700)]
Replace decode/encode with unscramble/buf_append_scrambled

The buf_append_XXX() approach is more idiomatic within the OpenConnect codebase, and these versions are a bit more efficient (fewer copies and no need for in-place reversing).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoReplace stack-allocated auth form with dynamically allocated auth form
Daniel Lenski [Mon, 21 Jun 2021 00:43:33 +0000 (17:43 -0700)]
Replace stack-allocated auth form with dynamically allocated auth form

See https://gitlab.com/openconnect/openconnect/-/merge_requests/207#note_606126537

Also, standardize names for 'cstp_options', and don't merge options (see
https://gitlab.com/openconnect/openconnect/-/merge_requests/207#note_606123313)

Rudimentarily tested by pointing at a known Internet-facing CheckPoint VPN server:

    $ ./openconnect --protocol=cp vpn.simmons.edu
    Enter user credentials:
    Username (or Challenge Response):foo
    Password, passcode, or PIN+tokencode (leave blank for Challenge Response):
    POST https://vpn.simmons.edu/clients/
    SSL negotiation with vpn.simmons.edu
    Connected to HTTPS on vpn.simmons.edu with ciphersuite (TLS1.2)-(ECDHE-RSA-SECP256R1)-(AES-256-GCM)
    > POST /clients/ HTTP/1.1
    > Host: vpn.simmons.edu
    > User-Agent: Open AnyConnect VPN Agent v8.10-526-g67da55d3-dirty
    > X-Pad: 000000000000000000000000000000000000000
    > Content-Type: application/x-www-form-urlencoded
    > Content-Length: 217
    >
    > (CCCclientRequest
    >     :RequestHeader (
    >         :id (2)
    >         :type (UserPass)
    >         :session_id ()
    >     )
    >     :RequestData (
    >         :client_type (TRAC)
    >         :username (2b204b)
    >         :password (362e4f)
    >     )
    > )
    Got HTTP response: HTTP/1.0 200 OK
    Date: Mon, 21 Jun 2021 00:57:03 GMT
    Server: Check Point SVN foundation
    Content-Type: text/html
    X-UA-Compatible: IE=EmulateIE7
    Connection: close
    X-Frame-Options: SAMEORIGIN
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    Content-Length: 374
    HTTP body length:  (374)
    < (CCCserverResponse
    <  :ResponseHeader (
    <  :id (2)
    <  :type (UserPass)
    <  :session_id ()
    <  :return_code (600)
    <  )
    <  :ResponseData (
    <  :authn_status (done)
    <  :is_authenticated (false)
    <  :error_message (01405e5044575a3535653a5c652d594a4168262c44216522265c2b237268702b3759394320653a352c272c6c)
    <  :error_id (0d721d0bff0c6c0a071706130e0d63026fff041b190a171f6e)
    <  :error_code (101)
    <  )
    < )
    Received error during authentication: Access denied - wrong user name or password  (code 101)
    Failed to complete authentication

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoReplace ipv4tostr with inet_ntop
Daniel Lenski [Mon, 21 Jun 2021 00:00:45 +0000 (17:00 -0700)]
Replace ipv4tostr with inet_ntop

ipv4tostr() was a reimplementation of inet_ntoa(), with the same problem (it
used a static string buffer).  We replaced all use of inet_ntoa() with
inet_ntop() in 71bf1d939f55ff206e9f149bcc1bf2f4be2d7450

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoRemove unnecessary oc_text_buf from handle_ip_ranges/gen_ranges
Daniel Lenski [Sun, 20 Jun 2021 23:10:25 +0000 (16:10 -0700)]
Remove unnecessary oc_text_buf from handle_ip_ranges/gen_ranges

This one can straightforwardly be replaced with asprintf(), since it's only
written in one place and not used for continuous appending.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoRevert "Implement rekey on session expiration."
Nick Krylov [Sun, 20 Jun 2021 12:21:29 +0000 (15:21 +0300)]
Revert "Implement rekey on session expiration."

This reverts commit 2273c40e11fbc0d583741748d4581cf42a1d49bb.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoRemove extra check.
Nick Krylov [Sun, 20 Jun 2021 11:58:10 +0000 (14:58 +0300)]
Remove extra check.

It is not needed as long as partial writes are disabled.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
3 years agoAllow incoming packet to be split across several TLS records.
Nick Krylov [Fri, 18 Jun 2021 13:24:55 +0000 (16:24 +0300)]
Allow incoming packet to be split across several TLS records.

Signed-off-by: Nick Krylov <krylovna@gmail.com>
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 agoBe defensive if input is malformed.
Nick Krylov [Fri, 18 Jun 2021 10:00:43 +0000 (13:00 +0300)]
Be defensive if input is malformed.

Signed-off-by: Nick Krylov <krylovna@gmail.com>