Commit Graph

30 Commits

Author SHA1 Message Date
Kevin Locke 62032567d3 strongswan: swanctl: make send_cert local
When support for send_cert was added in 4b9453b9a4, the $send_cert
variable was inadvertently global.  Make it local to avoid polluting the
global namespace and make the code easier to reason about.

Fixes: 4b9453b9a4 ("strongswan: Add support for send_cert option")
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2025-04-27 13:40:39 -06:00
Kevin Locke c1cfb36e50 strongswan: swanctl: Add support for encap
Support the [encap] connection configuration option to force UDP
encapsulation of ESP packets to work around connectivity issues with
middleboxes which block ESP packets.

This work is based on a patch by @aleks-mariusz in
https://forum.openwrt.org/t/confusion-regarding-setting-up-ikev2-vpn-service-with-strongswan-using-ipsec-and-swanctl/169587/9

[encap]: https://docs.strongswan.org/docs/latest/swanctl/swanctlConf.html#_connections

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2025-04-27 13:35:50 -06:00
Martin Pecka 88d1876f38 strongswan: Add support for EAP-MSCHAPv2 authentication
Support for EAP-MSCHAPv2 authentication scheme is added.

Different from the previously supported schemes, this one is
usually asymmetric in the way that server auth method (pubkey) is
different from the client auth method (eap-mschapv2).
The code handles this asymmetry automatically.

A new UCI config section mschapv2_secrets is added where the user
can specify the EAP identities and their passwords that are
accepted by the server. AFAIK, there is no way to select which
EAP IDs should be accepted by which remote, except setting
`eap_id` to something different than `%any`. But `eap_id`
does not support template matching, so either only a single
identity or all can be configured for one remote. This is why
the EAP identities are not subsections of remotes, but are
a standalone section.

Signed-off-by: Martin Pecka <peci1@seznam.cz>
Signed-off-by: Martin Pecka <peckama2@fel.cvut.cz>
2024-11-19 08:05:33 -08:00
Martin Pecka 6b824ee7d7 strongswan: Fix pools to be only generated once
Before this commit, if a user configures multiple remotes in UCI,
each remote generates one output section of pools.
This doesn't hurt because swanctl just merges all of them,
but it is apparently not needed to have N copies of the same.

This commit changes the behavior to only create one pools
section at the end of the generated swanctl config.

Signed-off-by: Martin Pecka <peci1@seznam.cz>
Signed-off-by: Martin Pecka <peckama2@fel.cvut.cz>
2024-11-19 08:05:33 -08:00
Martin Pecka 4b9453b9a4 strongswan: Add support for send_cert option
This option is required by some clients, e.g. iOS.

Signed-off-by: Martin Pecka <peci1@seznam.cz>
2024-11-19 08:05:33 -08:00
Philip Prindeville d95f6625e3 strongswan: Add missing declarations in swanctl
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2024-05-06 20:51:12 -06:00
Joel Low f2d209e4ff strongswan: trigger reload when interfaces are specified
Fixes #20848

Add interface triggers if interfaces to listen to are specified in
`/etc/config/ipsec`. This fixes the "running with no instances" scenario
after rebooting a router.

Signed-off-by: Joel Low <joel@joelsplace.sg>
2023-12-18 10:17:09 +08:00
Tiago Gaspar a7c7265e1b
strongswan: swanctl: add support for replay window
Add support for replay window configuration in UCI.

Signed-off-by: Tiago Gaspar <tiagogaspar8@gmail.com>
2023-11-17 09:25:36 +00:00
Philip Prindeville 7f8aea6d86 strongswan: make parsing more consistent
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2023-06-15 18:33:08 -06:00
Philip Prindeville 5f3840c765 strongswan: local_gateway unused in swanctl.init
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2023-04-22 18:20:38 -06:00
Glen Huang d347448ffb strongswan: add support for remote cacerts
Signed-off-by: Glen Huang <me@glenhuang.com>
2023-04-10 17:16:07 +08:00
Glen Huang 08a0f7bb94 strongswan: add support for pools section
Signed-off-by: Glen Huang <me@glenhuang.com>
2023-04-10 17:16:07 +08:00
Philip Prindeville 216b6b61a8 strongswan: simplify indentation
Allow passing multiple config lines with the same indent level.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2023-03-26 13:53:59 -06:00
Philip Prindeville 03eab9b63b strongswan: Fix indent for hw_offload, interface, priority
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2023-03-26 13:53:05 -06:00
Philip Prindeville 796443267f strongswan: Fix PSK's when using multiple connections
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2022-11-08 20:07:48 -07:00
Joel Low 5c8af06c94 strongswan: support child rekey by bytes and packets
This adds support for the child SA to be rekeyed through the byte/packet
threshold. The default is blank (which disables the byte/packet thresholds).

Signed-off-by: Joel Low <joel@joelsplace.sg>
2022-05-09 19:27:17 +08:00
Philip Prindeville d279a64df8 strongswan: add priority option
Also from Vincent Wiemann <vincent.wiemann@ironai.com>.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:45:43 -06:00
Philip Prindeville 6c79715676 strongswan: add ipcomp support
Also from Vincent Wiemann <vincent.wiemann@ironai.com>.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:34:45 -06:00
Philip Prindeville 11ff072672 strongswan: add interface option for children
This option sets the interface of the policy.

Also from Vincent Wiemann <vincent.wiemann@ironai.com>.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:31:31 -06:00
Philip Prindeville 0231e043b7 strongswan: add support for hw_offload
Also from Vincent Wiemann <vincent.wiemann@ironai.com>.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:31:31 -06:00
Philip Prindeville 0fe23b0e4a strongswan: miscellaneous cleanup of config file, etc
Use list's where appropriate for multi-value config variables.

Forbid absolute/relative paths for certificate and key files.

Get rid of last remnants of left/right naming.

Factor invariant code paths.

Drop redundant secrets.rsa.filename section.

Thanks to Vincent Wiemann <vincent.wiemann@ironai.com> for calling
out many of these improvements.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:31:31 -06:00
Philip Prindeville 09dcf7486d strongswan: rename config functions
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-27 16:31:31 -06:00
Vincent Wiemann 59732ba018 strongswan: fix PSK config generation
There were closing curly braces missing and it was checking for empty
strings while it should have been checking for non-empty strings.

Signed-off-by: Vincent Wiemann <vincent.wiemann@ironai.com>
2021-06-18 04:42:01 +02:00
Philip Prindeville 2ccd2665cb strongswan: fix sharing of ipsec section variables
Variables set in config_ipsec() need to be shared with do_postamble()
function, so change scoping to parent (prepare_env()).

Also, remove unused settings like "remote_sourceip", "reqid", and
"packet_marker".

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-17 09:46:55 -06:00
Philip Prindeville a783986cbc strongswan: start charon directly from swanctl
ipsec uses starter, and reads /etc/ipsec.conf (which then includes
/var/ipsec/ipsec.conf, etc). This is overly complicated, and can
be problematic if you're using both swanctl and ipsec for migration.

Running charon directly from procd via the init.d script avoid
all of this.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-06-02 00:23:54 -06:00
Philip Prindeville ba79998e52 strongswan: swanctl init script doesn't load connections
Fixes issue #15446

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-05-05 11:58:34 -06:00
Philip Prindeville ff33f4ccd3 strongswan: handle chacha20poly1305 as AEAD
chacha20policy1305 is also an AEAD cipher, and hence does not
permit a hash algorithm.

Fixes issue #15397.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-13 12:46:07 -06:00
Philip Prindeville c95fd69973 strongswan: fail on serious configuration errors
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-13 12:46:07 -06:00
Philip Prindeville 210640d606 strongswan: drop subshell when possible
A subshell caused by $(...) can't persistently modify globals as a
side-effect.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-13 12:45:57 -06:00
Philip Prindeville f9d91f1f47 strongswan: migrate to swanctl configs
Derived from the ipsec initd script, with the following changes:

(1) various code improvements, corrections (get rid of left/right
    updown scripts, since there's only one), etc;
(2) add reauth and fragmentation parameters;
(3) add x.509 certificate-based authentication;

and other minor changes.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2021-04-04 11:58:51 -06:00