From: Tobias Brunner Date: Tue, 4 Mar 2025 12:18:21 +0000 (+0100) Subject: testing: Add rw-eap-id-switch scenario X-Git-Tag: 6.0.2dr1~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4249d721ec28506e63e55d60e1d2951f67a5162f;p=thirdparty%2Fstrongswan.git testing: Add rw-eap-id-switch scenario --- diff --git a/testing/tests/ikev2/rw-eap-id-switch/description.txt b/testing/tests/ikev2/rw-eap-id-switch/description.txt new file mode 100644 index 0000000000..92ad49d48a --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/description.txt @@ -0,0 +1,5 @@ +The roadwarriors carol and dave set up a connection each to gateway moon. +The gateway requests an EAP-Identity and uses it to select an appropriate connection. +Based on dave's identity, the gateway requests an EAP-TLS certificate-based +client authentication. For carol, the gateway switches to a default config +that uses the EAP-MD5 password-based client authentication method. diff --git a/testing/tests/ikev2/rw-eap-id-switch/evaltest.dat b/testing/tests/ikev2/rw-eap-id-switch/evaltest.dat new file mode 100644 index 0000000000..18e1b3afcb --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/evaltest.dat @@ -0,0 +1,19 @@ +carol::swanctl --list-sas --raw 2> /dev/null::home.*version=2 state=ESTABLISHED local-host=192.168.0.100 local-port=4500 local-id=carol remote-host=192.168.0.1 remote-port=4500 remote-id=moon.strongswan.org initiator=yes.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519.*child-sas.*home.*state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[192.168.0.100/32] remote-ts=\[10.1.0.0/16]::YES +dave::swanctl --list-sas --raw 2> /dev/null::home.*version=2 state=ESTABLISHED local-host=192.168.0.200 local-port=4500 local-id=C=CH, O=strongSwan Project, OU=Accounting, CN=dave@strongswan.org remote-host=192.168.0.1 remote-port=4500 remote-id=moon.strongswan.org initiator=yes.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519.*child-sas.*home.*state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[192.168.0.200/32] remote-ts=\[10.1.0.0/16]::YES +moon:: swanctl --list-sas --ike-id 1 --raw 2> /dev/null::rw-eap-md5.*version=2 state=ESTABLISHED local-host=192.168.0.1 local-port=4500 local-id=moon.strongswan.org remote-host=192.168.0.100 remote-port=4500 remote-id=carol.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519.*child-sas.*net.*reqid=1 state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.1.0.0/16] remote-ts=\[192.168.0.100/32]::YES +moon:: swanctl --list-sas --ike-id 2 --raw 2> /dev/null::rw-eap-tls.*version=2 state=ESTABLISHED local-host=192.168.0.1 local-port=4500 local-id=moon.strongswan.org remote-host=192.168.0.200 remote-port=4500 remote-id=C=CH, O=strongSwan Project, OU=Accounting, CN=dave@strongswan.org.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519.*child-sas.*net.*reqid=2 state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.1.0.0/16] remote-ts=\[192.168.0.200/32]::YES +carol::cat /var/log/daemon.log::authentication of 'moon.strongswan.org' with RSA.* successful::YES +carol::cat /var/log/daemon.log::authentication of 'moon.strongswan.org' with EAP successful::YES +carol::cat /var/log/daemon.log::EAP method EAP_MD5 succeeded, no MSK established::YES +dave:: cat /var/log/daemon.log::authentication of 'moon.strongswan.org' with RSA.* successful::YES +dave:: cat /var/log/daemon.log::authentication of 'moon.strongswan.org' with EAP successful::YES +dave:: cat /var/log/daemon.log::EAP method EAP_TLS succeeded, MSK established::YES +moon:: cat /var/log/daemon.log::constraint check failed: EAP identity 'C=CH, O=strongSwan Project, OU=Accounting, CN=.*' (ID_DER_ASN1_DN) required, not matched by 'carol' (ID_FQDN)::YES +moon:: cat /var/log/daemon.log::authentication of 'carol' with EAP successful::YES +moon:: cat /var/log/daemon.log::authentication of 'C=CH, O=strongSwan Project, OU=Accounting, CN=dave@strongswan.org' with EAP successful::YES +carol::ping -c 1 PH_IP_ALICE::64 bytes from PH_IP_ALICE: icmp_.eq=1::YES +dave:: ping -c 1 PH_IP_ALICE::64 bytes from PH_IP_ALICE: icmp_.eq=1::YES +moon::tcpdump::IP carol.strongswan.org > moon.strongswan.org: ESP::YES +moon::tcpdump::IP moon.strongswan.org > carol.strongswan.org: ESP::YES +moon::tcpdump::IP dave.strongswan.org > moon.strongswan.org: ESP::YES +moon::tcpdump::IP moon.strongswan.org > dave.strongswan.org: ESP::YES diff --git a/testing/tests/ikev2/rw-eap-id-switch/hosts/carol/etc/strongswan.conf b/testing/tests/ikev2/rw-eap-id-switch/hosts/carol/etc/strongswan.conf new file mode 100644 index 0000000000..30536f744a --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/hosts/carol/etc/strongswan.conf @@ -0,0 +1,9 @@ +# /etc/strongswan.conf - strongSwan configuration file + +swanctl { + load = pem pkcs1 revocation constraints pubkey openssl random +} + +charon-systemd { + load = random nonce openssl pem pkcs1 curl revocation vici kernel-netlink socket-default eap-identity eap-md5 updown +} diff --git a/testing/tests/ikev2/rw-eap-id-switch/hosts/carol/etc/swanctl/swanctl.conf b/testing/tests/ikev2/rw-eap-id-switch/hosts/carol/etc/swanctl/swanctl.conf new file mode 100755 index 0000000000..451945ebb5 --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/hosts/carol/etc/swanctl/swanctl.conf @@ -0,0 +1,34 @@ +connections { + + home { + local_addrs = 192.168.0.100 + remote_addrs = 192.168.0.1 + + local { + auth = eap-md5 + id = carol + } + remote { + auth = pubkey + id = moon.strongswan.org + } + children { + home { + remote_ts = 10.1.0.0/16 + + updown = /usr/local/libexec/ipsec/_updown iptables + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + proposals = aes128-sha256-x25519 + } +} + +secrets { + + eap-carol { + id = carol + secret = Ar3etTnp + } +} diff --git a/testing/tests/ikev2/rw-eap-id-switch/hosts/dave/etc/strongswan.conf b/testing/tests/ikev2/rw-eap-id-switch/hosts/dave/etc/strongswan.conf new file mode 100644 index 0000000000..0ac5d700eb --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/hosts/dave/etc/strongswan.conf @@ -0,0 +1,9 @@ +# /etc/strongswan.conf - strongSwan configuration file + +swanctl { + load = pem pkcs1 revocation constraints pubkey openssl random +} + +charon-systemd { + load = random nonce openssl pem pkcs1 curl revocation vici kernel-netlink socket-default eap-identity eap-tls updown +} diff --git a/testing/tests/ikev2/rw-eap-id-switch/hosts/dave/etc/swanctl/swanctl.conf b/testing/tests/ikev2/rw-eap-id-switch/hosts/dave/etc/swanctl/swanctl.conf new file mode 100755 index 0000000000..fe0e7c3ad1 --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/hosts/dave/etc/swanctl/swanctl.conf @@ -0,0 +1,26 @@ +connections { + + home { + local_addrs = 192.168.0.200 + remote_addrs = 192.168.0.1 + + local { + auth = eap-tls + certs = daveCert.pem + } + remote { + auth = pubkey + id = moon.strongswan.org + } + children { + home { + remote_ts = 10.1.0.0/16 + + updown = /usr/local/libexec/ipsec/_updown iptables + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + proposals = aes128-sha256-x25519 + } +} diff --git a/testing/tests/ikev2/rw-eap-id-switch/hosts/moon/etc/strongswan.conf b/testing/tests/ikev2/rw-eap-id-switch/hosts/moon/etc/strongswan.conf new file mode 100644 index 0000000000..8b74972874 --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/hosts/moon/etc/strongswan.conf @@ -0,0 +1,9 @@ +# /etc/strongswan.conf - strongSwan configuration file + +swanctl { + load = pem pkcs1 revocation constraints pubkey openssl random +} + +charon-systemd { + load = random nonce openssl pem pkcs1 curl revocation vici kernel-netlink socket-default eap-identity eap-md5 eap-tls updown +} diff --git a/testing/tests/ikev2/rw-eap-id-switch/hosts/moon/etc/swanctl/swanctl.conf b/testing/tests/ikev2/rw-eap-id-switch/hosts/moon/etc/swanctl/swanctl.conf new file mode 100755 index 0000000000..7e0ac038e2 --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/hosts/moon/etc/swanctl/swanctl.conf @@ -0,0 +1,41 @@ +connections { + + rw-eap-tls { + local_addrs = 192.168.0.1 + + local { + auth = pubkey + certs = moonCert.pem + id = moon.strongswan.org + } + remote { + eap_id = "C=CH, O=strongSwan Project, OU=Accounting, CN=*" + auth = eap-tls + } + children { + net { + local_ts = 10.1.0.0/16 + + updown = /usr/local/libexec/ipsec/_updown iptables + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + proposals = aes128-sha256-x25519 + } + + rw-eap-md5 : connections.rw-eap-tls { + remote { + eap_id = %any + auth = eap-md5 + } + } +} + +secrets { + + eap-carol { + id = carol + secret = Ar3etTnp + } +} diff --git a/testing/tests/ikev2/rw-eap-id-switch/posttest.dat b/testing/tests/ikev2/rw-eap-id-switch/posttest.dat new file mode 100644 index 0000000000..e5c82ef20d --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/posttest.dat @@ -0,0 +1,6 @@ +carol::systemctl stop strongswan +dave::systemctl stop strongswan +moon::systemctl stop strongswan +moon::iptables-restore < /etc/iptables.flush +carol::iptables-restore < /etc/iptables.flush +dave::iptables-restore < /etc/iptables.flush diff --git a/testing/tests/ikev2/rw-eap-id-switch/pretest.dat b/testing/tests/ikev2/rw-eap-id-switch/pretest.dat new file mode 100644 index 0000000000..becb716214 --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/pretest.dat @@ -0,0 +1,12 @@ +moon::iptables-restore < /etc/iptables.rules +carol::iptables-restore < /etc/iptables.rules +dave::iptables-restore < /etc/iptables.rules +carol::cd /etc/swanctl; rm rsa/* x509/* +moon::systemctl start strongswan +carol::systemctl start strongswan +dave::systemctl start strongswan +moon::expect-connection rw-eap-md5 +carol::expect-connection home +carol::swanctl --initiate --child home 2> /dev/null +dave::expect-connection home +dave::swanctl --initiate --child home 2> /dev/null diff --git a/testing/tests/ikev2/rw-eap-id-switch/test.conf b/testing/tests/ikev2/rw-eap-id-switch/test.conf new file mode 100644 index 0000000000..1227b9d1c0 --- /dev/null +++ b/testing/tests/ikev2/rw-eap-id-switch/test.conf @@ -0,0 +1,25 @@ +#!/bin/bash +# +# This configuration file provides information on the +# guest instances used for this test + +# All guest instances that are required for this test +# +VIRTHOSTS="alice moon carol winnetou dave" + +# Corresponding block diagram +# +DIAGRAM="a-m-c-w-d.png" + +# Guest instances on which tcpdump is to be started +# +TCPDUMPHOSTS="moon" + +# Guest instances on which IPsec is started +# Used for IPsec logging purposes +# +IPSECHOSTS="moon carol dave" + +# charon controlled by swanctl +# +SWANCTL=1