Commit Graph
14752 Commits
Author SHA1 Message Date
Tobias Brunner f5b1ca4ef6 pf-handler: Fix build with musl C library
musl's headers define a lot of networking structs.  For some, the
definition in the Linux UAPI headers is then suppressed by e.g.
__UAPI_DEF_ETHHDR.

Since we included musl's net/ethernet.h, which includes netinet/if_ether.h
that defines `struct ethhdr` (and the above constant), **after** we
include linux/if_ether.h, there was a compilation error because the
struct was defined multiple times.

However, simply moving that include doesn't fix the problem because for
ARP-specific structs the Linux headers don't provide __UAPI_DEF* checks.
So instead of directly including the linux/ headers, we include those
provided by the C library.  For glibc these usually just include the
Linux headers, but for musl this allows them to define the struct
directly.  We also need to move if.h and add packet.h, which define
other structs (or include headers that do so) that we use.

Fixes: 187c72d1af ("dhcp: Port the plugin to FreeBSD/macOS")
2024-03-22 11:40:15 +01:00
Thomas Egerer f3c8e02c69 ike-sa-manager: Unlock mutex if allocating SPI fails to avoid lock contention
Fixes: 5d91d8c469 ("Check rng return value when generating SPIs in ike_sa_manager_t")
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2024-03-20 13:18:57 +01:00
Wataru Ashihara c3f8642e72 save-keys: Fix Wireshark algorithm identifier for 3DES
Wireshark has shown the following error dialogue because the identifier
was incorrect [1]:

Error loading table 'ESP SAs': esp_sa:18: invalid value: TripleDes-CBC [RFC2451]

[1] https://github.com/wireshark/wireshark/blob/3757f42e5f0a8ee6b14a117a2fd99af759a31d98/epan/dissectors/packet-ipsec.c#L203

Closes strongswan/strongswan#2013
2024-03-18 08:54:41 +01:00
Tobias Brunner 9acd90575a ike-cfg: Change how OCSP certificate requests are enabled
The previous option caused such requests to be enabled if not explicitly
disabled, which only the vici plugin did, for all other backends requests
would have been sent.

References strongswan/strongswan#2016
2024-03-15 15:38:19 +01:00
Tobias Brunner cfc7be004d peer-cfg: Renumber ocsp_policy_t values so the same default applies for all backends
Only the vici plugin previously set OCSP_SEND_REPLY explicitly, all other
backends would have defaulted to OCSP_SEND_BOTH.

References strongswan/strongswan#2016
2024-03-15 15:37:50 +01:00
Tobias Brunner a2ace8a6bb kernel-pfroute: Log ignored interfaces when listing known interfaces 2024-03-15 13:47:23 +01:00
Tobias Brunner e9df6f5c3d kernel-netlink: Log ignored interfaces when listing known interfaces 2024-03-15 13:45:08 +01:00
Tobias Brunner b2f957f5f1 pkcs11: Fix cleanup when verifying signature fails because scheme isn't supported
Fixes: 49769fff53 ("pkcs11: Support RSA-PSS signatures")
2024-03-14 13:58:02 +01:00
Tobias Brunner c035e4ca93 smp: Make code that encodes identities more readable
In particular for static code analyzers.  The previous nesting of case
statements inside of a while loop that's inside a switch statement and
a wrapping block with declaration was quite weird and Coverity didn't
like it (it figured that `type` was uninitialized even when it assumed
that get_type() returned a known type for which a case statement
existed).
2024-03-14 13:51:06 +01:00
Tobias Brunner 500207e35c systime-fix: Fix declaration of validator constructor 2024-03-13 16:50:46 +01:00
Tobias Brunner 6628c523c2 unit-tests: Point out if ECDSA public key was rejected after private keys was not
AWS-LC rejects public keys with explicitly encoded parameters but allows
private keys that use explicit encodings of the NIST curves.  Since the
more important aspect is that public keys are rejected, this addition to
the warning message points that out.

References strongswan/strongswan#1907
2024-03-13 16:47:20 +01:00
Jean-François HrenandTobias Brunner 15612b3a42 Add support for IKEv2 OCSP extensions (RFC 4806)
Closes strongswan/strongswan#2016

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2024-03-13 15:10:50 +01:00
Tobias Brunner b29be6029e constraints: Properly validate name constraints according to RFC 5280
The previous code was in a way too simple which resulted in it being too
strict.  For instance, it enforced that intermediate CA certificates
inherited the name constraints of their parents.  That's not required by
RFC 5280 and prevented e.g. adding constraints in an intermediate CA
certificate that's followed by another that doesn't contain any
name constraints.  That's perfectly fine as the set of constraints
specified by the parent continue to apply to that CA certificate and
the children it issues.

Name constraints were previously also applied to all identities of a
matching type, which is way too strict except for some very simple
cases.  It basically prevented multiple constraints of the same type
as e.g. an intermediate CA certificate that has permitted name constraints
for example.org and example.com couldn't issue acceptable certificates
because any SAN with one domain would get rejected by the other
constraint.  According to RFC 5280 matching one constraint is enough.

Also fixed is an issue with name constraints for IP addresses which were
previously only supported for a single level.
2024-03-12 09:14:44 +01:00
Tobias Brunner ea6a6344d3 identification: Add support to match subnets/ranges against each other
Previously, it was only possible to match addresses against subnets and
ranges, but not the other way around or subnets and ranges against each
other.
2024-03-12 09:14:44 +01:00
Etay Bogner fac42f7168 starter: Use correct type for uniqueids field
Enum arguments (ARG_ENUM with .list != LST_bool) are assumed to be of
type/size int in assign_args() in args.c.

Fixes: 0644ebd3de ("implemented IKE_SA uniqueness using ipsec.conf uniqueids paramater additionally supports a "keep" value to keep the old IKE_SA")

Closes strongswan/strongswan#2148
2024-03-07 15:08:00 +01:00
Gerardo Ravago 8237968c2c leak-detective: Add whitelist entries for AWS-LC
AWS-LC (and likely BoringSSL) uses thread specific data to store internal
library state which gets freed via a registered destructor when the thread
terminates. If this thread happens to be the main thread, which runs the
leak-detective evaluation, the detective won't observe the corresponding free
of the related memory and erroneously reports it as a leak.

The two places this happens are:
- `RAND_bytes` for storing internal RNG state.
- `ERR_put_error` for storing the per-thread OpenSSL error queue.

References strongswan/strongswan#1907
Closes strongswan/strongswan#2147
2024-03-07 15:06:40 +01:00
Gerardo Ravago 44e241fccc openssl: Handle BoringSSL-style ASN1_INTEGERs in cert serials
OpenSSL stores the serial number for an X509 certificate as an
`ASN1_INTEGER` type. Within BoringSSL (and AWS-LC), the library
represents the value of zero as an empty array [1] which is different
from OpenSSL which represents it as the 1-byte array [0x00]. Though the
value of zero for the certificate serial number is illegal under
X.509 [2], we need to handle/encode it consistently within strongSwan.
From 18082ce2b0 ("certificates: Retrieve serial numbers in canonical
form"), we infer that the canonical representation of the zero serial
is [0x00]. To do this, we introduce `openssl_asn1_int2chunk` to
complement the existing string version that allows us to handle the
special case for zero instead of always returning a reference to the
library-dependent encodings.

References strongswan/strongswan#1907
Closes strongswan/strongswan#2138

[1] https://github.com/google/boringssl/commit/bdc35b63617f78037768f4897d8835696f02181a
[2] https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2
2024-03-05 08:51:16 +01:00
Andreas Steffen 06afb5f109 cert-enroll: add init.d support to cert-install-sssd 2024-03-03 17:12:48 +01:00
Tobias Brunner f994e0a428 utils: Define ignore_result() so it requires a semicolon
It previously also added its own empty statement.
2024-02-29 16:02:28 +01:00
Tobias Brunner 6dee8587f0 Remove obvious empty statements (i.e. stray semicolons) 2024-02-29 15:30:40 +01:00
Tobias Brunner a380dc4989 utils: Define DESTROY_*_IF() macros without terminating semicolon
This avoids double semicolons (i.e. empty statements) and is how
DESTROY_IF() is already defined.
2024-02-29 09:06:43 +01:00
Tobias Brunner b21178b43c android: New release after adding fix for existing shortcuts/Intents 2024-02-26 11:14:14 +01:00
Tobias Brunner 45371da846 android: Add fallback for the old name of the profile ID extra
This fixes existing shortcuts and automation via Intents.

Fixes: 8e3b921abe ("android: Always use UUID to access profiles")
2024-02-26 11:01:55 +01:00
Tobias Brunner 1f5aa8017f Revert "kernel-netlink: Never use XFRMA_REPLAY_ESN_VAL to configure zero replay windows"
This reverts commit 8b9b11919d.

Since ESN was negotiated via proposal, just configuring the SA without
ESN won't work as the ICV will be incorrect if the peer enabled ESN
on its SA.  While the Linux kernel currently doesn't support disabling
replay protection for SAs that use ESN, this at least gets users an
explicit error not just dropped packets, and it will automatically work
if the kernel supports this combination at some point.

References strongswan/strongswan#2117
2024-02-23 18:00:32 +01:00
Tobias Brunner 7db629e4bc android: New release after adding support for managed configurations 2024-02-21 12:24:53 +01:00
Tobias Brunner 51a5d96b36 android: Add translations for managed configuration strings
Not actually translating anything, but making the linter happy.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer 8c6b3019a7 android: Update managed certificates if config changes 2024-02-21 12:24:53 +01:00
Markus Pfeiffer b0ba845e27 android: Add manager for managed user certificates
This can be used to install, replace or delete currently installed user
certificates based on the app's current managed configuration.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer aa06d75491 android: Add manager for managed trusted certificates
This is used to install, replace or delete currently installed trusted
certificates based on the app's current managed configuration.

Certificates that are shared between multiple profiles are protected
and not uninstalled if a profile that uses it remains.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer 9cb23f650a android: Add utility class to determine differences in two lists of objects
This allows determining the difference between two lists in the form of
inserts, updates and deletes (and unchanged elements).
2024-02-21 12:24:53 +01:00
Markus Pfeiffer 97cb35afe5 android: Add repository for managed user certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer 99dfa8cb0e android: Add repository for managed trusted certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer a04798a796 android: Add base repository for installed managed certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer cd67c30fd1 android: Add installer for managed user certificates/keys
This installs the configured user certificate into Android's key store
using the DevicePolicyManager.

This is only accessible if the app is installed on an enrolled device and
has been granted the CERT_INSTALL delegate scope.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer fb302d967c android: Add installer for managed trusted certificates
This installs a configured CA or server certificate into the app's local
key store.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer e2f505350e android: Add database migration for managed certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer 6882f17741 android: Add trusted and user certificates to ManagedVpnProfile 2024-02-21 12:24:53 +01:00
Markus Pfeiffer 9cbc03e84f android: Add entities for CA/server and user certificates 2024-02-21 12:24:53 +01:00
Markus Pfeiffer 22bce57e4c android: Add utility that parses a PKCS#12 container and extracts a KeyPair 2024-02-21 12:24:53 +01:00
Markus Pfeiffer 4ac9fc327e android: Add utility that converts a Base64 string to a X509Certificate 2024-02-21 12:24:53 +01:00
Markus Pfeiffer afcb56400e android: Add utility class that pairs a certificate with a private key 2024-02-21 12:24:53 +01:00
Markus Pfeiffer 8a50651212 android: Add password for client certificate to managed config 2024-02-21 12:24:53 +01:00
Markus Pfeiffer 9a917252e2 android: Provide global database helper instance 2024-02-21 12:24:53 +01:00
Markus Pfeiffer 861ac0109a android: Extend database helper with table definition
This simplifies database migration.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer 802047cae8 android: Move database helper into separate class
Reduce strong coupling between database helper and VPN profiles, to
prepare for the addition of other tables.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer 42626c1dd8 android: Hide unmanaged profiles by default
Such profiles could exist if a user already had strongSwan installed.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer 0af501ef26 android: Disable access to settings depending on managed configuration 2024-02-21 12:24:53 +01:00
Markus Pfeiffer fe13782e3c android: Hide menu items depending on managed configuration
Hide and disable menu items when disabled by the managed configuration.
2024-02-21 12:24:53 +01:00
Markus Pfeiffer 4bfeb3b000 android: Add data source for managed VPN profiles
Include the managed VPN profile data source in the profile source,
to show profiles from both sources in the UI.
2024-02-21 12:24:53 +01:00
Tobias Brunner 8f04d15dfd android: Expose static instance for Application object
While it seems to be possible to cast Context.getApplicationContext()
to the application class, there really is no documented reason why that
should actually be the same object.
2024-02-21 12:24:53 +01:00