Commit Graph

17485 Commits

Author SHA1 Message Date
Andreas Steffen d470422974 Version bump to 5.9.0dr2 2020-06-14 12:15:44 +02:00
Tobias Brunner 84bce03a64 testing: Fix SQL scenarios after preferring AEAD for ESP
sql/net2net-route|start-pem seem to be the only ones that configure a
proposal via database.
2020-06-12 13:45:58 +02:00
Tobias Brunner 4261f915d6 testing: Fix ikev2/net2net-fragmentation scenario
The IKE_AUTH message from moon is now larger because of the AEAD proposal.
2020-06-12 13:45:58 +02:00
Tobias Brunner 33412158f5 ike: Send AEAD ESP default proposal first
We generally prefer AEAD nowadays.

References #3461.
2020-06-12 13:47:13 +02:00
Tobias Brunner c7bef954ee proposal: Add AES-GCM to the ESP default AEAD proposal
References #3461.
2020-06-12 13:45:58 +02:00
Tobias Brunner bc40509057 ikev2: Ensure ALERT_RETRANSMIT_SEND_CLEARED is triggered
If a MOBIKE task is deferred, the retransmission counter is reset to 0
when reinitiating.  So if there were retransmits before, this alert would
not be triggered if a response is received now without retransmits.
2020-06-11 13:33:32 +02:00
Tobias Brunner 4b225bf866 travis: Don't pipe negative lgtm.com result into jq
The data might not be valid JSON.
2020-06-11 13:29:47 +02:00
Tobias Brunner 364d8b2628 ikev1: Ensure local IP is known as identity fallback during Main Mode
We usually have a local IP already via ike_sa_t::resolve_hosts() before
build_i() is called but if that's not the case, it's more likely we have
one after we processed the first response (it might also have changed).
There is a potential chance we still don't have one if the socket API
doesn't provide us with the destination address of received messages,
but that seems not very likely nowadays.
2020-06-11 13:29:47 +02:00
Andreas Steffen 12e4dbb231 Version bump to 5.9.0dr1 2020-06-06 15:02:42 +02:00
Tobias Brunner 59ebdac49b child-create: Don't reset DH group when retrying after INVALID_KE_PAYLOAD
migrate() is called before retrying.

Fixes: 0184a69b7b ("child-create: Properly handle DH group during
migration when reestablishing")
2020-06-05 16:41:23 +02:00
Tobias Brunner 736ac65554 ikev1: Fix PSK lookup for Main Mode initiators
We need the PSK/identity already when deriving the keys in process_i().

Fixes: 1665a4e050 ("ikev1: Use actual local identity as initiator or aggressive mode responder")
2020-06-05 14:26:30 +02:00
Tobias Brunner 62367f2c01 ike: Fix retransmission timeouts if base is <= 1
Fixes: 72b282cf20 ("ike: Properly support high number of retransmission tries")
2020-06-05 13:44:00 +02:00
Tobias Brunner a5e4322348 android: New release after improving connectivity/scheduling 2020-06-02 14:55:58 +02:00
Tobias Brunner 763f07c531 travis: Add build of the Android app 2020-06-02 14:42:38 +02:00
Tobias Brunner eadba6d225 android: Suppress linting error in manifest related to cert import activity
<data> tags that only specify the mimeType attribute are perfectly fine
according to the docs.
2020-06-02 14:42:48 +02:00
Tobias Brunner 93d6fe3e4a android: Ignore some missing quantity lint errors
Once these strings are translated and the quantities are defined, this
attribute can be removed again.
2020-06-02 14:42:45 +02:00
Tobias Brunner 84924249aa android: Mock parseInetAddress() method to fix unit tests
The native parseInetAddressBytes() method called by that method is not
available when running the tests.

Not very pretty and there are some warnings because PowerMock does
reflection in some illegal way but it fixes the unit tests and does
not require any new dependencies like Apache Commons or Guava just to
parse IP addresses without DNS lookup.

Fixes: 2ef473be15 ("android: Use helper to parse IP addresses where appropriate")
Fixes #3443.
2020-06-02 14:42:38 +02:00
Tobias Brunner a22a1493c3 Merge branch 'android-scheduler'
Starting with Android 6, the system will aggressively suspend apps when
the device is idle (Doze mode).  With Android 10 on a Pixel 4 this seems
to happen after about 70 minutes.  Then the scheduler thread in our
default scheduler is only woken rarely, combined with our previous use
of the monotonic clock it meant that events were executed with severe
delays and noticing that there was such a delay.  This was particularly
bad in regards to NAT keepalives as it usually meant that the device was
not reachable anymore from the outside.

Some changes here try to improve that situation, e.g. the clock is switched
to CLOCK_REALTIME (Bionic doesn't support CLOCK_BOOTTIME for condvars) so we
can measure the actual difference e.g. since the last outbound message,
other changes try to ensure that connectivity is restored after being asleep
for a while (send DPD instead of keepalive after a long delay, send DPD even
if path to peer stays the same).

However, the most significant change is the replacement of the default
scheduler with one specifically designed for Android.  It schedules
long-term events via AlarmManager, which allows waking up the app even
if the system put it to sleep.  The latter requires adding the app to the
system's battery optimization whitelist, which is requested from the
user automatically if necessary.  With this, NAT keepalives and rekeyings
are now scheduled accurately, with little changes to the battery usage.
If the app is not whitelisted (there is a setting to ignore this), events
are delayed by up to 15 minutes after about 70 minutes, so behind a NAT
the device won't be reachable from the outside afterwards (connectivity
should be restored as soon as the device is woken from deep sleep by the
user).

Fixes #3364.
2020-06-02 14:34:31 +02:00
Tobias Brunner 04f4bef235 android: Add a preference flag to ignore battery optimizations
This allows users to ignore whether the app is on the device's power
whitelist without a warning.  The flag is currently not set
automatically if the user denies the request.
2020-06-02 14:07:06 +02:00
Tobias Brunner 5d01aaf91d android: Increase lifetimes a bit
This should avoid clashes of soft and hard lifetimes even if the app is
not whitelisted.
2020-06-02 14:07:06 +02:00
Tobias Brunner a0d32a2d13 android: Ask user to add our app to the device's power whitelist
This is necessary so we can actually schedule events accurately in Doze
mode. Otherwise, we'd only get woken in intervals of several minutes (up to
15 according to the docs) after about an hour.
2020-06-02 14:07:06 +02:00
Tobias Brunner d67a5b0c4d android: Use the default scheduler for short-term events
Using AlarmManager has quite some overhead, so we use our regular
scheduler for events that are to be executed in the near future.
2020-06-02 14:07:06 +02:00
Tobias Brunner 1b4c4123c2 android: Use Android-specific scheduler on Android 6 and later 2020-06-02 14:07:06 +02:00
Tobias Brunner b7d66ae2cd android: Add Android-specific implementation of scheduler_t
This uses AlarmManager to schedule events in a way that ensures the app
is woken up (requires whitelisting when in Doze mode to be woken up at
the exact time, otherwise there are delays of up to 15 minutes).
2020-06-02 14:07:06 +02:00
Tobias Brunner aaa908dc0a scheduler: Use timercmp(3) instead of a custom function 2020-06-02 14:07:06 +02:00
Tobias Brunner 2edc73d84e ike: Only track actually sent retransmits as outbound packets
Retransmission jobs for old requests for which we already received a
response previously left the impression that messages were sent more
recently than was actually the case.

task_manager_t always defined INVALID_STATE as possible return value if
no retransmit was sent, this just was never actually returned.

I guess we could further differentiate between actual invalid states
(e.g. if we already received the response) and when we don't send a
retransmit for other reasons e.g. because the IKE_SA became stale.
2020-06-02 14:07:06 +02:00
Tobias Brunner f3695d089b android: Change how initial log handler is registered
Previously, if the two utility functions were called while the VPN
connection was established (i.e. charon was initialized) the logger for
libstrongswan would get reset to the initial log handler.  So certain
log messages would not get logged to the log file after the TUN device
was created (one of the helpers is used to convert IPs there).
2020-06-02 14:07:06 +02:00
Tobias Brunner 070cd12dfb android: Check the current path using DPD after a roaming event
A new NAT mapping might be created even if the IP stays the same.  Due to
the DPD fallback with NAT keep-alives this might only be necessary in
corner cases, if at all.
2020-06-02 14:07:06 +02:00
Tobias Brunner 6524bd3cd5 ike: Optionally use DPD to check if the current path still works
We could maybe check the duration of the last stale condition or when
the last packet was sent as filter to avoid unnecessary updates.
2020-06-02 14:07:06 +02:00
Tobias Brunner 664389ebc4 android: Enable switch from NAT interval to DPDs after 20 seconds 2020-06-02 14:07:06 +02:00
Tobias Brunner 0d4a5f6af6 ike: Add an option to trigger a DPD instead of a NAT keepalive
This is useful on Android where the app might not be able to send
keep-alives if the device is asleep for a while.  If the NAT mapping
has been deleted in the mean time, the NAT-D payloads allow detecting
this and connectivity can be restored by doing a MOBIKE update or
recreating the SA if the peer already deleted it because the client
wasn't reachable.
2020-06-02 14:07:06 +02:00
Tobias Brunner 31298187bf android: Switch to CLOCK_REALTIME on Android
This allows measuring the delay between events more accurately if a
device is often suspended.

While CLOCK_BOOTTIME would be preferable, Android's bionic C library
does not support it for condvars.
2020-06-02 13:57:37 +02:00
Tobias Brunner 3e358475bb time: Allow using different clocks
On some systems it might be preferable to use e.g. CLOCK_BOOTTIME
instead of CLOCK_MONOTONIC, which is also not affected by time
adjustments but includes times when the system was suspended.
2020-06-02 13:57:37 +02:00
Tobias Brunner 8b93510dac mutex: Don't use ...timedwait_monotonic() if clock is set via attribute
This allows using clocks other than CLOCK_MONOTONIC.
2020-06-02 13:57:37 +02:00
Tobias Brunner 6b3bf7cdac ike: Track NAT-keepalives as outbound packets 2020-06-02 13:57:37 +02:00
Tobias Brunner 491cdd59bd android: Fix app icon on Android versions < 5.0
XML resources are apparently not supported there.  Moving the icon to
the mipmap folders should fix that.  Aliases are defined for the icons on
Android < 8.0.
2020-06-02 13:57:37 +02:00
Tobias Brunner 3c8280960c android: Update Gradle plugin 2020-06-02 13:57:37 +02:00
Tobias Brunner 907a31db4c android: Again change how data source is handled in TileService
Evidently, onClick() may be called either before onStartListening() or
after onStopListening() has been called, which causes a crash when
trying to load a VpnProfile via mDataSource.

This partially reverts 3716af079e ("android: Avoid crash related to
TileService on Huawei devices").
2020-06-02 13:57:37 +02:00
Tobias Brunner 0ff939585e travis: Bump tpm2-tss to 2.4.1
Manually built dependencies are now built in a separate step after
packages have been installed as they might depend themselves on some
packages (e.g. tpm2-tss, which now requires libjson-c).
2020-05-26 11:06:07 +02:00
Thomas 04db34a3a7 charon-nm: Allow configurable remote traffic selectors
This change allows to customize the previously hard-coded remote traffic
selectors.

This does not actually write the newly added "remote-ts" configuration option
into NetworkManager's configuration file, but will use an existing value.
Exposing the config setting in the GUI could be done later if this is a
desired change.

Use case:  remote firewall appliance wrongly accepts the `0.0.0.0/0` TS but
does not actually route external traffic, leaving the user with a partially
working internet connection.

Closes strongswan/strongswan#173.
2020-05-25 11:50:46 +02:00
Tobias Brunner 3a54206c08 ikev2: Return to the original host if connection fails after redirection
If we fail connecting to the host we got redirected to, we should restart
with the original host where we might get redirected to a different host.

We must not reset this when retrying due to INVALID_KE_PAYLOAD or COOKIE
notifies.  Since we keep the initiator SPI in those cases, we use that
flag as indicator.

Since we don't store the original remote_host value, we can't restore
that.  So there is a potential conflict with MIPv6.

Closes strongswan/strongswan#171.
2020-05-19 17:33:20 +02:00
Tobias Brunner 3f454f33c0 nm: Version bump to 1.5.2 2020-05-19 16:17:05 +02:00
Tobias Brunner 1ebf63b966 nm: Move server port to options tab and position tabs to the left
Also shortened the title of the proposal tab.  This saves some additional
screen space.

Fixes #3448.
2020-05-19 16:17:24 +02:00
Tobias Brunner 7b15ecf82e nm: Use tabs for options/proposals to save screen space
The height of the dialog increased due to the recently added additional
fields for certificate selection and identities.  On some screens the
fields to configure custom proposals were not visible anymore.
Together with less spacing on the top level GtkBox this change reduces
the height by about 80 pixels.

Fixes #3448.
2020-05-19 16:17:05 +02:00
Tobias Brunner 73b60338dc nm: Migrate appdata to metainfo
The path '/usr/share/appdata' is deprecated as is the .appdata.xml
extension, files should be in installed in '/usr/share/metainfo' with
a .metainfo.xml extension.

According to the docs, the metainfo path should be well supported even
by older distros like Ubuntu 16.04.

Reference: 2.1.2. Filesystem locations
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html
2020-05-11 09:57:37 +02:00
Tobias Brunner ecf187509a nm: Version bump to 1.5.1 2020-05-08 18:12:20 +02:00
Tobias Brunner d5d8375610 charon-nm: Clear secrets when disconnecting
The need_secrets() method is called before connect() (where we clear the
previous secrets too), so e.g. a password-protected private could be
decrypted with the cached password from earlier but if the password was not
stored with the connection, it would later fail as no password was requested
from the user that could be passed to connect().

References #3428.
2020-05-08 18:12:20 +02:00
Tobias Brunner 532d5fc85d nm: Fix password entry for private keys and allow saving it
On newer desktops the auth dialog is called with --external-ui-mode and
it seems that the password flag has to be set, otherwise the password is
not stored temporarily in the profile and passed to charon-nm (not sure
how this works exactly as need_secrets() is called multiple times even
after the password was already entered, only before doing so the last
time is the password available in that callback, but only if the flag
was set).  This now also allows storing the password for the private key
with the profile.

Fixes #3428.
2020-05-08 18:11:41 +02:00
Tobias Brunner 72b282cf20 ike: Properly support high number of retransmission tries
Due to the exponential backoff a high number of retransmits only
makes sense if retransmit_limit is set.  However, even with that there
was a problem.

We first calculated the timeout for the next retransmit and only then
compared that to the configured limit.  Depending on the configured
base and timeout the calculation overflowed the range of uint32_t after
a relatively low number of retransmits (with the default values after 23)
causing the timeout to first get lower (on a high level) before constantly
resulting in 0 (with the default settings after 60 retransmits).

Since that's obviously lower than any configured limit, all remaining
retransmits were then sent without any delay, causing a lot of concurrent
messages if the number of retransmits was high.

This change determines the maximum number of retransmits until an
overflow occurs based on the configuration and defaults to UINT32_MAX
if that value is exceeded.  Note that since the timeout is in milliseconds
UINT32_MAX equals nearly 50 days.

The calculation in task_manager_total_retransmit_timeout() uses a double
variable and the result is in seconds so the maximum number would be higher
there (with the default settings 1205).  However, we want its result to
be based on the actual IKE retransmission behavior.
2020-05-07 15:05:55 +02:00
Tobias Brunner 066fa42fcb ike-auth: Add option to use EAP-only authentication without notify
Some peers apparently don't send the notify and still expect to
authenticate with EAP-only authentication.  This option allows forcing
the configured use of EAP-only authentication in that scenario.
2020-05-07 15:05:55 +02:00