]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
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 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 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>
3 years agoRemove NULL checks before deinit GnuTLS objects.
Tom Carroll [Wed, 12 May 2021 07:46:08 +0000 (00:46 -0700)]
Remove NULL checks before deinit GnuTLS objects.

GnuTLS handles these just like a traditional free() function and copes
if they're NULL. We don't have to check.

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoConvert x509_privkey to abstract privkey in load_certificates.
Tom Carroll [Wed, 12 May 2021 07:46:06 +0000 (00:46 -0700)]
Convert x509_privkey to abstract privkey in load_certificates.

Prefer the use of privkey to x509_privkey, reducing branches in later code.

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
3 years agoRemove field free_certs from gtls_cert_info.
Tom Carroll [Wed, 12 May 2021 07:46:03 +0000 (00:46 -0700)]
Remove field free_certs from gtls_cert_info.

There was only one place in the code requiring special treatment supported by
free_cert == 0. Instead, make a copy of the certificate, transforming the case
to free_cert == 1. This allows the removal of free_certs from the gtls_cert_info
structure.

Signed-off-by: Tom Carroll <incentivedesign@gmail.com>
3 years agoGnuTLS: Refactor test sign/verify loop over available digests
David Woodhouse [Mon, 17 May 2021 10:25:11 +0000 (11:25 +0100)]
GnuTLS: Refactor test sign/verify loop over available digests

Some compilers don't like the loop and switch statement for setting 'dig':

warning: ‘dig’ may be used uninitialized in this function [-Wmaybe-uninitialized

It's a false positive, since we only looped over the values that are
handled in the switch statement and which *do* set 'dig'.

But let's refactor it a little anyway, to make it less obscure for humans
and compilers alike.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd openconnect_get_connect_url(), use it in --authenticate output connect-url
David Woodhouse [Fri, 14 May 2021 10:57:11 +0000 (11:57 +0100)]
Add openconnect_get_connect_url(), use it in --authenticate output

As noted in the long comment in openconnect.h, we need to provide the
actual *URL* for the connection including the real hostname. And that
means we also need to provide a suitable --resolve argument to pass on
to the connecting openconnect.

Add openconnect_get_connect_url() for the GUI auth-dialogs to use, and
make 'openconnect --authenticate' emit the same. If we just put it into
$HOST that might break existing setups that don't use the newly-added
$RESOLVE variable too, so put it in another new variable $CONNECT_URL
and leave the original $HOST alone.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoUpdate translations from GNOME
David Woodhouse [Fri, 14 May 2021 07:00:08 +0000 (08:00 +0100)]
Update translations from GNOME

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

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoUpdate TPMv2 documentation a little, add changelog for TLSv1.3 and swtpm
David Woodhouse [Thu, 13 May 2021 16:04:21 +0000 (17:04 +0100)]
Update TPMv2 documentation a little, add changelog for TLSv1.3 and swtpm

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoActually add P384 files so they aren't generated locally
David Woodhouse [Thu, 13 May 2021 14:31:41 +0000 (15:31 +0100)]
Actually add P384 files so they aren't generated locally

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd NIST P384 curve to swtpm tests
David Woodhouse [Thu, 13 May 2021 14:13:40 +0000 (15:13 +0100)]
Add NIST P384 curve to swtpm tests

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoDisable swtpm testing for ancient Fedora/EPEL
David Woodhouse [Thu, 13 May 2021 14:13:22 +0000 (15:13 +0100)]
Disable swtpm testing for ancient Fedora/EPEL

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd swtpm-tools to COPR build too, to enable auth-swtpm test
David Woodhouse [Thu, 13 May 2021 13:27:29 +0000 (14:27 +0100)]
Add swtpm-tools to COPR build too, to enable auth-swtpm test

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd tests for TPMv2 with both swtpm and hardware
David Woodhouse [Tue, 11 May 2021 12:45:18 +0000 (13:45 +0100)]
Add tests for TPMv2 with both swtpm and hardware

For normal builds, the auth-swtpm test runs a new swtpm with a temporary
state directory, imports a pregenerated TPM state which matches the
keys that are also pregenerated and committed to git.

As with the normal keys/certs and SoftHSM state, there are also rules
for *generating* all this, to ensure that what's committed is entirely
reproducible and serve as documentation. But those rules are mostly
dormant from this point onwards (hence my not caring about parallel
builds being broken for the swtpm startup).

There's an attempt at supporting *real* TPM testing, with a 'hwtpm'
variant. In that case the rules for generating the key/cert and for
importing the existing EC cert into the TPM are *not* dormant. But
this isn't quite working yet and is going to need to be an explicit
invocation by those who care about such things.

There are three keys tested here. Firstly the original EC key used
by all our certificate tests, imported into the TPM with the
create_tpm2_key tool from James's openssl_tpm2_engine. We cannot
import our original RSA key as it deliberately had a strange key
size, and the TPM can't cope.

Then we *generate* EC and RSA keys in the TPM too, using the
tpm2tss-genkey tool from the Intel engine. That one isn't capable
of importing existing keys yet but *is* more widely available in
distro packages.

For swtpm we use both since it's only necessary for the tools to be
present at the time we add all this. For hwtpm where users will want
to do this at build/test time, they get a subset of the keys depending
on which tools they have available.

We preserve the existing nomenclature for matching keys/certs, where
NAME-key-STORAGETYPE.pem matches with NAME-cert.pem. So the *imported*
version of our existing EC key ends up being ec-key-swtpm.pem and
ec-key-hwtpm.pem to match the existing ec-cert.pem

For the *generated* keys, we need a new 'NAME' since they are actually
new keys. So 'swtpm-ec' 'swtpm-rsa' 'hwtpm-ec' 'hwtpm-rsa' are the names
of those keys, and since they were generated in the TPM and never
existed as a file, we need a new pattern-match rule to generate the
corresponding CSR and then certificate, using the ENGINE to do so.

But we want this pattern rule *not* to match the imported keys like
ec-key-swtpm.pem, because we don't want to trigger a generation of
ec-cert.pem from the TPM when it's already right there in a file.

So we *don't* want to use 'swtpm' and 'hwtpm' as the STORAGETYPE part of
the filenames of the generated keys; we just use 'tpm' instead, and then
the pattern rule matches 'swtpm-%-key-tpm.pem' and 'hwtpm-%-key-tpm.pem'.

This doesn't yet test NV-parented keys or any kind of passwords, but
it's a start.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAllow TPM_INTERFACE_TYPE=socsim to force swtpm even for Intel TSS
David Woodhouse [Thu, 13 May 2021 12:04:59 +0000 (13:04 +0100)]
Allow TPM_INTERFACE_TYPE=socsim to force swtpm even for Intel TSS

If we want to have a swtpm-based test, we need to *use* the swtpm even
if a real hardware TPM is available. Not for general purpose use, but
allow it to be overridden by using the same TPM_INTERFACE_TYPE variable
that already works for the IBM TSS because the IBM library handles it
internally.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoUpdate translations from GNOME
David Woodhouse [Wed, 12 May 2021 22:05:37 +0000 (23:05 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoResync translations with sources
David Woodhouse [Wed, 12 May 2021 22:03:00 +0000 (23:03 +0100)]
Resync translations with sources

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoImplement RSA-PSS padding for TPMv2
David Woodhouse [Wed, 12 May 2021 15:19:07 +0000 (16:19 +0100)]
Implement RSA-PSS padding for TPMv2

Now I can connect using TLSv1.3 using a TPMv2 RSA key. And my list of
"stuff I should never have had to do for myself in the application,
just to ask the crypto library to use the key that the user pointed
it at" has *really* jumped the shark now.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd IBM TSS CI build on Fedora
David Woodhouse [Wed, 12 May 2021 20:19:40 +0000 (21:19 +0100)]
Add IBM TSS CI build on Fedora

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAllow TSS2 library to be chosen by --with-gnutls-tss2
David Woodhouse [Wed, 12 May 2021 20:00:26 +0000 (21:00 +0100)]
Allow TSS2 library to be chosen by --with-gnutls-tss2

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoSupport TLSv1.3 sign functions on SECP curves with TPMv2
David Woodhouse [Tue, 11 May 2021 21:09:24 +0000 (22:09 +0100)]
Support TLSv1.3 sign functions on SECP curves with TPMv2

For these curves at least, it basically already works.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoTell TPMv2 the hash type based on size
David Woodhouse [Tue, 11 May 2021 20:49:33 +0000 (21:49 +0100)]
Tell TPMv2 the hash type based on size

The TPM doesn't really have any business knowing this, and the only thing
that matters is the size. Which is truncated to the curve bit length even
for larger hashes.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agotss2-esys: Don't try password for TPM2 keys with emptyauth set
David Woodhouse [Tue, 11 May 2021 12:42:52 +0000 (13:42 +0100)]
tss2-esys: Don't try password for TPM2 keys with emptyauth set

The auth-certificate test always sets --key-password=password, and when
a TPM2 key has 'emptyauth' the IBM TSS code was trying the empty auth
first, as it should. But the Esys code was always trying the password,
and then prompting the user; the user had to just press enter.

Try empty auth first if the key says so.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoGnuTLS: Fix user-visible strings and dialog auth_id for multicert
David Woodhouse [Mon, 10 May 2021 09:21:01 +0000 (10:21 +0100)]
GnuTLS: Fix user-visible strings and dialog auth_id for multicert

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoOpenSSL: Fix user-visible strings and dialog auth_id for multicert
David Woodhouse [Sun, 9 May 2021 18:34:34 +0000 (19:34 +0100)]
OpenSSL: Fix user-visible strings and dialog auth_id for multicert

The visible messages and the keys in the dialog prompts should make it
clear whether they are for the primary or secondary cert.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoOpenSSL: Factor out load_certificate() from load_primary_certificate()
David Woodhouse [Sat, 8 May 2021 13:27:30 +0000 (14:27 +0100)]
OpenSSL: Factor out load_certificate() from load_primary_certificate()

Much the same as we've done on the GnuTLS side, separate out *loading*
the certificate, from installing it into the SSL_CTX.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoGnuTLS: Move TPMv2 context to certinfo
David Woodhouse [Sat, 8 May 2021 07:48:16 +0000 (08:48 +0100)]
GnuTLS: Move TPMv2 context to certinfo

Precisely the same as we just did for TPMv1, to make the TPM context
per-cert instead of per-vpninfo.

As with TPMv1, some of this *could* be global state in the future.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoGnuTLS: Move TPMv1 context to certinfo
David Woodhouse [Sat, 8 May 2021 07:41:12 +0000 (08:41 +0100)]
GnuTLS: Move TPMv1 context to certinfo

If we want to support multiple certificates, the TPM context needs to
be managed per cert, not per vpninfo.

Strictly, some of this *could* be global state while some of it is
per-key. But that's an optimisation for the future.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoGnuTLS: Really only install certs from load_primary_certificate()
David Woodhouse [Fri, 7 May 2021 16:05:59 +0000 (17:05 +0100)]
GnuTLS: Really only install certs from load_primary_certificate()

Finally actually finish the job: load_certificate() fetches the key
and certs into a data structure that its caller can use as it sees
fit, and the *caller* then installs them into the https_cred in
the case of the primary certificate.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoGnuTLS: Split out free_gtls_cert_info()
David Woodhouse [Fri, 7 May 2021 15:47:48 +0000 (16:47 +0100)]
GnuTLS: Split out free_gtls_cert_info()

If we want load_certificate() to actually *return* this stuff to its
caller for real and then load_primary_certificate() to actually install
them into the https_cred, then we're going to have to be able to free
it sanely.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoGnuTLS: Extend certinfo to callbacks
David Woodhouse [Fri, 7 May 2021 15:01:43 +0000 (16:01 +0100)]
GnuTLS: Extend certinfo to callbacks

Now that the cert_info struct has a back-reference to the vpninfo, we
can use it as the private data for callbacks.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoOpenSSL: Pass certinfo through load_certificate() functions
David Woodhouse [Fri, 7 May 2021 14:44:37 +0000 (15:44 +0100)]
OpenSSL: Pass certinfo through load_certificate() functions

Much like in GnuTLS except in GnuTLS we already separated out the bit
which installs the key/certs into the https_cred while all these
OpenSSL functions are still just installing directly into the SSL_CTX
so we're going to want to fix that separately.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoGnuTLS: Pass certinfo into load_certificate() and subordinate functions
David Woodhouse [Fri, 7 May 2021 14:24:51 +0000 (15:24 +0100)]
GnuTLS: Pass certinfo into load_certificate() and subordinate functions

Instead of blindly referencing vpninfo->certinfo[0], pass the required
certinfo pointer into load_certificate() and down to the various
subfunctions which get invoked from there.

A couple of places still need fixing; notably gnutls_pin_callback() and
auth_tpm2_key(). Both of which are *callbacks*. I think we'll end up
adding a self-referencing vpninfo pointer to the struct cert_info, then
using the cert_info as the 'private' data for those callbacks. But that
can come later.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoMove cert/sslkey/cert_password into a 'struct cert_info'
David Woodhouse [Fri, 7 May 2021 14:03:20 +0000 (15:03 +0100)]
Move cert/sslkey/cert_password into a 'struct cert_info'

This paves the way for having more than one of them.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoGnuTLS: Start to factor out load_certificate() for reuse
David Woodhouse [Fri, 7 May 2021 13:53:45 +0000 (14:53 +0100)]
GnuTLS: Start to factor out load_certificate() for reuse

Introduce a struct with the key/cert information and start pretending
that the load_certificate() function is only obtaining those, and add a
load_primary_certificate() function which will actually be responsible
for installing them into vpninfo->https_cred.

This is step 1 which isn't even pretending very hard; it's just adding
the structure and doing a search/replace to use the fields therein
instead of local variables in load_certificate().

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agokill redundant free_certs argument to GnuTLS assign_privkey() function
David Woodhouse [Fri, 7 May 2021 10:33:31 +0000 (11:33 +0100)]
kill redundant free_certs argument to GnuTLS assign_privkey() function

This was added in commit 04ccc265c ("Simplify extra_certs handling
w.r.t. assign_privkey()") because GnuTLS 2 didn't take a copy of the
certs which were assigned to the creds, and we needed to keep track of
which extra certs were used and which weren't.

The GnuTLS 3 variant of assign_privkey() didn't use it, since GnuTLS 3
takes a copy of the certs and we can just free them normally.

Now that we've dropped GnuTLS 2 support, we can drop this argument too
and simplify assign_privkey() a little bit.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoFix Coverity complaints about array.c
David Woodhouse [Thu, 6 May 2021 19:33:05 +0000 (20:33 +0100)]
Fix Coverity complaints about array.c

A couple of leaks on error paths, and there are only three DNS servers
in ip_info.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoOnly require json-parser for Fedora packages, not EPEL
David Woodhouse [Wed, 5 May 2021 22:22:25 +0000 (23:22 +0100)]
Only require json-parser for Fedora packages, not EPEL

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd documentation for array protocol, remove HIDDEN flag
David Woodhouse [Wed, 5 May 2021 21:36:07 +0000 (22:36 +0100)]
Add documentation for array protocol, remove HIDDEN flag

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoImplement DTLS support for Array
David Woodhouse [Tue, 4 May 2021 17:58:42 +0000 (18:58 +0100)]
Implement DTLS support for Array

This is fairly straightforward once you spot the "13" at the end of the
first DTLS packet. Without that, we can *send* data and even do keepalives
but the worker process on the server would crash the moment it has actual
*packets* to send back to us.

Like fairly much every other SSL VPN using anonymous DTLS, they don't
cope well with that first DTLS packet (or the response to it) being
lost. We don't get anything back if we resend it. And if we send a
keepalive that *might* elicit a response... or might cause them to tear
down the connection if they haven't seen the initial auth packet yet.

So... we send only the auth packet first. If we don't see a response we
send the auth packet *and* a keepalive in quick succession. If we start
seeing IP packets (which includes the keepalive as that's Legacy IP
protocol #0xff), we jump to DTLS_ESTABLISHED state too.,

We also need to send a 'dtls off' packet when we want it to switch back
to sending over TCP, much like the oNCP queue_esp_control().

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoStart to implement config parsing for Array
David Woodhouse [Sat, 1 May 2021 13:41:39 +0000 (14:41 +0100)]
Start to implement config parsing for Array

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd hackish array auth
David Woodhouse [Sat, 1 May 2021 11:33:21 +0000 (12:33 +0100)]
Add hackish array auth

It's woefully incomplete but it means I don't have to mess with curl
each time.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoInitial shell of Array Networks SSL VPN support
David Woodhouse [Thu, 19 Mar 2020 11:46:06 +0000 (11:46 +0000)]
Initial shell of Array Networks SSL VPN support

Can't resist a packet dump...

https://gitlab.com/openconnect/openconnect/issues/102

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agojson_parse_ex: Remove redundant assignment to unused 'b'.
David Woodhouse [Sat, 1 May 2021 18:22:30 +0000 (19:22 +0100)]
json_parse_ex: Remove redundant assignment to unused 'b'.

The static analyser complains 'Value stored to 'b' is never read'.

There isn't even much of a defence that it's just being defensive; we
ought to *know* it isn't used from that point on.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agojson: Fix undefined behaviour when converting integer to double
David Woodhouse [Sat, 1 May 2021 18:48:57 +0000 (19:48 +0100)]
json: Fix undefined behaviour when converting integer to double

Coverity doesn't like this, complaining that assignment to an object
with overlapping storage without exact overlap and compatible types can
cause undefined behaviour.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoImport json-parser library
David Woodhouse [Sat, 1 May 2021 12:21:18 +0000 (13:21 +0100)]
Import json-parser library

Imported v1.1.1 from https://github.com/ShahinSorkh/json-parser

Commit 7c46f9c ("bump package version to 1.1.1")

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoUse BIO_dgram for OpenSSL DTLS
David Woodhouse [Wed, 5 May 2021 20:48:24 +0000 (21:48 +0100)]
Use BIO_dgram for OpenSSL DTLS

This way it can find a sane MTU and doesn't have to fragment the handshake
packets, which the Array server can't cope with.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoFix DTLS state reporting
David Woodhouse [Wed, 5 May 2021 17:24:02 +0000 (18:24 +0100)]
Fix DTLS state reporting

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoImprove Fortinet auth
Daniel Lenski [Wed, 5 May 2021 17:18:55 +0000 (10:18 -0700)]
Improve Fortinet auth

Use the same 'auth_id' values as GlobalProtect uses ('_login' for the normal
username/password form, and '_challenge' for the MFA challenge form). This
is a follow-on to 613fa87dd64853a042d982aca4a94279cd78ff58.

This also fixes:

- A potential double-free() issue if the challenge form is loaded repeatedly,
  adding a test of 2 rounds of challenge 2FA to verify it.
- Warnings about the unused 'invalid_cookie' label.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'add_GP_flask_tests' of gitlab.com:openconnect/openconnect
David Woodhouse [Wed, 5 May 2021 07:02:49 +0000 (08:02 +0100)]
Merge branch 'add_GP_flask_tests' of gitlab.com:openconnect/openconnect

3 years agoMerge branch 'do_not_use_inet_ntoa' of gitlab.com:openconnect/openconnect
David Woodhouse [Wed, 5 May 2021 07:02:02 +0000 (08:02 +0100)]
Merge branch 'do_not_use_inet_ntoa' of gitlab.com:openconnect/openconnect

3 years agoopenssl: Add SSL_OP_LEGACY_SERVER_CONNECT to allow-insecure-crypto
David Woodhouse [Tue, 4 May 2021 16:05:49 +0000 (17:05 +0100)]
openssl: Add SSL_OP_LEGACY_SERVER_CONNECT to allow-insecure-crypto

OpenSSL 3.0.0 onwards will require secure negotiation by default, which
Cisco servers don't seem to cope with. Let --allow-insecure-crypto turn
that off.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
3 years agoAdd OPENSSL_SUPPRESS_DEPRECATED
David Woodhouse [Tue, 4 May 2021 15:31:46 +0000 (16:31 +0100)]
Add OPENSSL_SUPPRESS_DEPRECATED

We will eventually update to the OpenSSL 3.0.0 APIs but for now there
is no overriding need to, so shut the warnings up the easy way.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>