Commit Graph

2148 Commits

Author SHA1 Message Date
Tobias Brunner ecf161e517 vici: Move Python test dir and include it in sdist
This is the recommended location and import config as it allows running the
tests against installed versions of the package.  And while the test file
itself is automatically included in the source distribution this way, the
__init__.py file is not, so we still have to update MANIFEST.in.
2020-01-14 16:53:19 +01:00
Tobias Brunner b723431540 vici: Run Python tests via tox if available
Since we use the serial test harness we can't use AM_TESTS_ENVIRONMENT.
The script is necessary for out-of-tree builds.
2020-01-14 15:26:52 +01:00
Tobias Brunner 574621d80a vici: Fix several PEP8 issues 2020-01-14 15:26:32 +01:00
Tobias Brunner d5153c5897 vici: Add tox.ini to run tests with tox
Some of the interpreters might not be available on the host system, use
--skip-missing-interpreters to not fail in that case.
2020-01-14 15:26:29 +01:00
Tobias Brunner c170bb593b vici: List newer Python versions in setup.py 2020-01-14 10:48:53 +01:00
Tobias Brunner a3166c8188 kernel-netlink: Use correct config option name for HW offloading check
Fixes: a605452c03 ("kernel-netlink: Check for offloading support in constructor")
2019-12-13 17:20:51 +01:00
Tobias Brunner d3ca9fcda4 attr: Remove unused/undeclared argument in provider constructor 2019-12-09 11:05:25 +01:00
Tobias Brunner c81a8a8f36 kernel-netlink: Properly compare routes for policies without gateway/netxhop
This happened when installing a duplicate bypass policy for a locally
connected subnet.  The destructor and the kernel-net part already
handle this correctly.
2019-12-06 10:28:13 +01:00
Tobias Brunner ae9b748a77 vici: Log certificate constraints for loaded configs 2019-12-06 10:07:47 +01:00
Martin Willi 3c71a3201f vici: Introduce a ca_id option identity based CA certificate constraints 2019-12-06 10:07:46 +01:00
Tobias Brunner 7035340b21 farp: Ignore SAs with 0.0.0.0/0 remote traffic selector
This is mostly to avoid hijacking the local LAN if the farp plugin is
inadvertently active on a roadwarrior.

Fixes #3116.
2019-12-06 10:06:16 +01:00
Tobias Brunner 202c204785 farp: Only cache IPv4 traffic selectors
Since ARP is IPv4 only there is no point caching IPv6 traffic
selectors/CHILD_SAs.
2019-12-06 09:58:29 +01:00
Tobias Brunner 1352413272 vici: Update Python egg if strongSwan version changed
Mainly useful when using the build-strongswan script of the testing
environment.
2019-11-28 16:52:30 +01:00
Tobias Brunner d592ff72bc stroke: Remove obsolete certificate registration for hash-and-URL 2019-11-26 11:12:26 +01:00
Tobias Brunner ad14f3a60d vici: Remove obsolete certificate registration for hash-and-URL 2019-11-26 11:12:26 +01:00
Tobias Brunner ae06cfad36 ike-cert-post: Generate URL for hash-and-URL here
This avoids having to register certificates with authority/ca backends
beforehand, which is tricky for intermediate CA certificates loaded
themselves via authority/ca sections.  On the other hand, the form of
these URLs can't be determined by config backends anymore (not an issue
for the two current implementations, no idea if custom implementations
ever made use of that possibility).  If that became necessary, we could
perhaps pass the certificate to the CDP enumerator or add a new method
to the credential_set_t interface.
2019-11-26 11:12:26 +01:00
Thomas Egerer a605452c03 kernel-netlink: Check for offloading support in constructor
This avoids races that could potentially occur when doing the check during
SA installation.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2019-11-26 11:00:28 +01:00
Tobias Brunner f3d8179b4b kernel-pfkey: Add additional strings for extensions on different platforms
Don't define structs for macOS as we don't need them (that's true for
most of the others too, though) and at least one is defined inside an extra
ifdef.
2019-10-28 14:26:32 +01:00
Tobias Brunner 45c8399d78 Add missing strings to several enum string definitions 2019-10-28 14:26:32 +01:00
Tobias Brunner 1bf58f6ad8 kernel-netlink: Support extended table IDs for custom routes
This adds support for installing routes in tables with IDs > 255.
2019-10-25 16:21:22 +02:00
Tobias Brunner 08d0342ca6 vici: List additional information for deleted CHILD_SAs
If a CHILD_SA is terminated, the updown event is triggered after the
CHILD_SA is set to state CHILD_DELETED, so no usage stats or detail
information like SPIs were reported.  However, when an IKEv2 SA is
terminated, the updown event for its children is triggered without
changing the state first, that is, they usually remain in state
INSTALLED and detailed data was reported in the event.  IKEv1
CHILD_SAs are always terminated individually, i.e. with state
change and no extra data so far.

With this change usage stats are also returned for individually deleted
CHILD_SAs as long as the SA has not yet expired.

Fixes #3198.
2019-10-25 16:15:42 +02:00
Tobias Brunner 62e7c68b61 kernel-pfkey: Clear receive buffer before sending request
Many of the messages sent by the kernel, including confirmations to our
requests, are sent as broadcasts to all PF_KEY sockets.  So if an
external tool is used to manage SAs/policies (e.g. unrelated to IPsec)
the receive buffer might be filled, resulting in errors like these:

  error sending to PF_KEY socket: No buffer space available

To avoid this, just clear the buffer before sending any message.

Fixes #3225.
2019-10-25 13:53:06 +02:00
Tobias Brunner a2cb2c9cc8 proposal: Add selection flags to clone() method
This avoids having to call strip_dh() in child_cfg_t::get_proposals().
It also inverts the ALLOW_PRIVATE flag (i.e. makes it SKIP_PRIVATE) so
nothing has to be supplied to clone complete proposals.
2019-10-24 17:43:21 +02:00
Tobias Brunner 9f12b8a61c kernel-netlink: Enumerate temporary IPv6 addresses according to config
This way we announce only permanent addresses via MOBIKE by default, and
temporary ones if the option is enabled.
2019-10-22 14:14:44 +02:00
Tobias Brunner 64795cc416 kernel-netlink: Don't enumerate deprecated IPv6 addresses 2019-10-22 14:13:32 +02:00
Andreas Steffen ea41f759b3 stroke: List drbgs in list_algs 2019-10-18 16:24:39 +02:00
Andreas Steffen c738704ab6 vici: List drbgs in get_algorithms 2019-10-16 16:46:24 +02:00
Patryk Duda 121390fb3c kernel-pfkey: Pass ESN flag to kernel if ESN is enabled
This patch adds passing the ESN flag to the kernel if ESN was negotiated
and the appropriate flag is present in the kernel headers, which will
be the case in future FreeBSD releases.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
Closes strongswan/strongswan#155.
2019-10-14 18:03:34 +02:00
Felix Kaiser 7c74ce9190 vici: Use unique names for CHILD_SAs in the child-updown event too
The unique names were introduced for the list-sas command in commit
04c0219e55.  However, the child-updown
event wasn't updated to match.  Even though the documentation suggests
that the section name of the CHILD_SAs are the same in both messages.

The original name is already being returned in the "name" attribute,
so it'll still be available.

Example:

    >>> import vici, json
    >>> s = vici.Session()

    # First, for comparison, the list-sas command:
    >>> print(json.dumps(list(s.list_sas()), sort_keys=True, indent=4, separators=(',', ': ')))
    [
        {
            "vti0": {
                "child-sas": {
                    "vti0-1": {
                        ...

    # A child-updown event before the change:
    >>> for x in s.listen(["child-updown"]): print(json.dumps(x, sort_keys=True, indent=4, separators=(',', ': ')))
    [
        "child-updown",
        {
            "vti0": {
                "child-sas": {
                    "vti0": {   # <-- wrong: inconsistent with list-sas
                        ...

    # A child-updown event after the change:
    >>> s = vici.Session()
    >>> for x in s.listen(["child-updown"]): print(json.dumps(x, sort_keys=True, indent=4, separators=(',', ': ')))
    [
        "child-updown",
        {
            "vti0": {
                "child-sas": {
                    "vti0-1": {  # <-- fixed

Closes strongswan/strongswan#153.
2019-10-04 10:11:18 +02:00
Tobias Brunner 17c9972252 Fixed some typos, courtesy of codespell 2019-08-28 14:03:41 +02:00
Tobias Brunner 9543a771dd updown: Pass the local interface the traffic to the peer actually takes
If the local IP is not on the interface the peer is reached through,
firewall rules will be installed with the wrong interface.

Fixes #3095.
2019-08-26 10:55:01 +02:00
Tobias Brunner a1295ff9cb load-tester: Add digitalSignature keyUsage flag to test certificate
This allows using the certificate, which is technically a CA cert, as
end-entity certificate again after the RFC4945-related changes added
with 5.6.3.

Fixes #3139.
2019-08-22 15:33:14 +02:00
Tobias Brunner b9949e98c2 Some whitespace fixes
Didn't change some of the larger testing scripts that use an inconsistent
indentation style.
2019-08-22 15:18:06 +02:00
SophieK 3aa7b2dc3a Avoid enumerating certificates with non-matching key type
If the key type was specified but the ID was NULL or matched a subject, it
was possible that a certificate was returned that didn't actually match
the requested key type.

Closes strongswan/strongswan#141.
2019-05-21 10:22:30 +02:00
Tobias Brunner 3ee352a691 smp: Use correct printf specifier to print SPIs 2019-05-08 14:48:54 +02:00
Tobias Brunner c7a0b39bd6 vici: Add Python command wrappers to tarball
Fixes: e0f7da8644 ("vici: Extract command wrappers in Python bindings")
2019-05-06 15:51:05 +02:00
Tobias Brunner 02b348403a Fixed some typos, courtesy of codespell 2019-04-29 15:09:20 +02:00
Tobias Brunner eefa81120c vici: Update command wrappers in the Perl bindings
Note that load_key() now returns the complete response (to get the key
identifier).
2019-04-26 10:15:48 +02:00
Tobias Brunner 968866afc6 vici: Update some data in the Ruby gemspec 2019-04-26 10:15:48 +02:00
Tobias Brunner cc2ef8f8a7 vici: Some code style fixes in the Ruby bindings
As reported by rubocop (some issues were not fixed, in particular
related to class/method length metrics).
2019-04-26 10:15:43 +02:00
Tobias Brunner 1fef01af58 vici: Update command wrappers of the Ruby bindings
Also reorder them to match README.md.
2019-04-26 09:35:37 +02:00
Tobias Brunner 3b39444556 vici: Refactor how commands are called in the Ruby bindings
Also expose a method to call arbitrary commands, which allows calling not
yet wrapped commands. Exceptions are raised for all commands if the response
includes a negative "success" key (similar to how it's done in the Python
bindings).
2019-04-26 09:35:11 +02:00
Tobias Brunner 42fe703a95 vici: Fix formatting of return values for load-conn and load-authority commands 2019-04-26 09:35:10 +02:00
Tobias Brunner c5113c8105 vici: Add missing command wrappers for Python bindings
Also change some for which the return value became relevant.
2019-04-26 09:35:10 +02:00
Tobias Brunner e0f7da8644 vici: Extract command wrappers in Python bindings
This simplifies the interface and allows calling not yet wrapped
commands more easily.
2019-04-26 09:18:54 +02:00
Tobias Brunner 89c8ba525b eap-aka-3gpp2: Increase SQN after each authentication 2019-04-25 15:58:17 +02:00
Tobias Brunner c863960eb1 vici: Support initiation of IKE_SAs
The configuration must allow the initiation of a childless IKE_SA (which
is already the case with the default of 'accept').
2019-04-25 15:23:19 +02:00
Tobias Brunner 2889b77da2 vici: Make childless initiation of IKE_SAs configurable 2019-04-25 15:23:19 +02:00
Tobias Brunner 9486a2e5b0 ike-cfg: Pass arguments as struct 2019-04-25 14:31:33 +02:00
Tobias Brunner 8da7dbe766 socket-default: Fix setting DSCP value on FreeBSD
Fixes #3030.
2019-04-23 11:49:04 +02:00