From: Andreas Steffen Date: Tue, 30 Mar 2021 20:05:49 +0000 (+0200) Subject: testing: Migrated p2pnat/medsrv-psk scenario to vici X-Git-Tag: 5.9.3dr1~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=66ba50b21768d2832ba0e563e3d39d1f1a11711d;p=thirdparty%2Fstrongswan.git testing: Migrated p2pnat/medsrv-psk scenario to vici --- diff --git a/testing/tests/p2pnat/medsrv-psk/evaltest.dat b/testing/tests/p2pnat/medsrv-psk/evaltest.dat index 55ada8cdfd..f917ab0fdd 100644 --- a/testing/tests/p2pnat/medsrv-psk/evaltest.dat +++ b/testing/tests/p2pnat/medsrv-psk/evaltest.dat @@ -1,11 +1,9 @@ -alice::ipsec status 2> /dev/null::medsrv.*ESTABLISHED.*6cu1UTVw@medsrv.org.*carol@strongswan.org::YES -bob:: ipsec status 2> /dev/null::medsrv.*ESTABLISHED.*av9oEPMz@medsrv.org.*carol@strongswan.org::YES -carol::ipsec status 2> /dev/null::medsrv.*ESTABLISHED.*PH_IP_MOON.*6cu1UTVw@medsrv.org::YES -carol::ipsec status 2> /dev/null::medsrv.*ESTABLISHED.*PH_IP_SUN.*v9oEPMz@medsrv.org::YES -alice::ipsec status 2> /dev/null::peer.*ESTABLISHED.*alice@strongswan.org.*bob@strongswan.org::YES -bob:: ipsec status 2> /dev/null::peer.*ESTABLISHED.*bob@strongswan.org.*alice@strongswan.org::YES -alice::ipsec status 2> /dev/null::peer.*INSTALLED, TUNNEL::YES -bob:: ipsec status 2> /dev/null::peer.*INSTALLED, TUNNEL::YES +alice::swanctl --list-sas --ike-id 2 --raw 2> /dev/null::medsrv.*version=2 state=ESTABLISHED local-host=10.1.0.10 local-port=4500 local-id=6cu1UTVw@medsrv.org remote-host=192.168.0.100 remote-port=4500 remote-id=carol@strongswan.org.*nat-local=yes nat-any=yes encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519::YES +bob::swanctl --list-sas --ike-id 1 --raw 2> /dev/null::medsrv.*version=2 state=ESTABLISHED local-host=10.2.0.10 local-port=4500 local-id=av9oEPMz@medsrv.org remote-host=192.168.0.100 remote-port=4500 remote-id=carol@strongswan.org.*nat-local=yes nat-any=yes encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519::YES +carol::swanctl --list-sas --ike-id 2 --raw 2> /dev/null::medsrv.*version=2 state=ESTABLISHED local-host=192.168.0.100 local-port=4500 local-id=carol@strongswan.org remote-host=192.168.0.1 remote-port=.*remote-id=6cu1UTVw@medsrv.org.*nat-remote=yes nat-any=yes encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519::YES +carol::swanctl --list-sas --ike-id 1 --raw 2> /dev/null::medsrv.*version=2 state=ESTABLISHED local-host=192.168.0.100 local-port=4500 local-id=carol@strongswan.org remote-host=192.168.0.2 remote-port=.*remote-id=av9oEPMz@medsrv.org.*nat-remote=yes nat-any=yes encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519::YES +alice::swanctl --list-sas --ike-id 1 --raw 2> /dev/null::peer.*version=2 state=ESTABLISHED local-host=10.1.0.10 local-port=4500 local-id=alice@strongswan.org remote-host=192.168.0.2 remote-port=.*remote-id=bob@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.*peer.*reqid=1 state=INSTALLED mode=TUNNEL protocol=ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.1.0.10/32] remote-ts=\[10.2.0.10/32]::YES +bob::swanctl --list-sas --ike-id 2 --raw 2> /dev/null::peer.*version=2 state=ESTABLISHED local-host=10.2.0.10 local-port=4500 local-id=bob@strongswan.org remote-host=192.168.0.1 remote-port=.*remote-id=alice@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.*peer.*reqid=1 state=INSTALLED mode=TUNNEL protocol=ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.2.0.10/32] remote-ts=\[10.1.0.10/32]::YES alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES bob:: ping -c 1 PH_IP_ALICE::64 bytes from PH_IP_ALICE: icmp_.eq=1::YES moon::tcpdump::IP moon.strongswan.org.* > sun.strongswan.org.*: UDP::YES diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/ipsec.conf b/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/ipsec.conf deleted file mode 100644 index 6ac413a1bd..0000000000 --- a/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/ipsec.conf +++ /dev/null @@ -1,34 +0,0 @@ -# /etc/ipsec.conf - strongSwan IPsec configuration file - -config setup - -conn %default - ikelifetime=60m - keylife=20m - rekeymargin=3m - keyingtries=1 - keyexchange=ikev2 - mobike=no - dpdaction=restart - dpddelay=60s - left=%defaultroute - leftfirewall=yes - -conn medsrv - leftid=6cu1UTVw@medsrv.org - leftauth=psk - right=PH_IP_CAROL - rightid=carol@strongswan.org - rightauth=pubkey - mediation=yes - auto=add - -conn peer - leftcert=aliceCert.pem - leftid=alice@strongswan.org - right=%any - rightid=bob@strongswan.org - rightsubnet=PH_IP_BOB/32 - mediated_by=medsrv - me_peerid=av9oEPMz@medsrv.org - auto=start diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/ipsec.secrets b/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/ipsec.secrets deleted file mode 100644 index 59396bbeb3..0000000000 --- a/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/ipsec.secrets +++ /dev/null @@ -1,7 +0,0 @@ -# /etc/ipsec.secrets - strongSwan IPsec secrets file - -: RSA aliceKey.pem - -# secret used for mediation connection - -6cu1UTVw@medsrv.org : PSK "BAXz/6cSITttd0CzF9799p859Pi4LPnP" diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/strongswan.conf b/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/strongswan.conf index 93f4345989..7625e5066e 100644 --- a/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/strongswan.conf +++ b/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/strongswan.conf @@ -1,5 +1,5 @@ # /etc/strongswan.conf - strongSwan configuration file charon { - load = random nonce aes sha1 sha2 pem pkcs1 curve25519 gmp x509 curl revocation hmac stroke kernel-netlink socket-default updown + load = random nonce aes sha1 sha2 pem pkcs1 curve25519 gmp x509 curl revocation hmac vici kernel-netlink socket-default updown } diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/swanctl/swanctl.conf b/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/swanctl/swanctl.conf new file mode 100755 index 0000000000..5cad5a6543 --- /dev/null +++ b/testing/tests/p2pnat/medsrv-psk/hosts/alice/etc/swanctl/swanctl.conf @@ -0,0 +1,54 @@ +connections { + + medsrv { + remote_addrs = 192.168.0.100 + + local { + auth = psk + id = 6cu1UTVw@medsrv.org + } + remote { + auth = pubkey + id = carol@strongswan.org + } + + version = 2 + mobike = no + mediation = yes + proposals = aes128-sha256-x25519 + } + + peer { + local { + auth = pubkey + certs = aliceCert.pem + id = alice@strongswan.org + } + remote { + auth = pubkey + id = bob@strongswan.org + } + children { + peer { + remote_ts = 10.2.0.10 + + start_action = start + updown = /usr/local/libexec/ipsec/_updown iptables + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + mobike = no + mediated_by = medsrv + mediation_peer = av9oEPMz@medsrv.org + proposals = aes128-sha256-x25519 + } +} + +secrets { + + ike-medsrv { + id = 6cu1UTVw@medsrv.org + secret = 0sBAXz/6cSITttd0CzF9799p859Pi4LPnP + } +} diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/ipsec.conf b/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/ipsec.conf deleted file mode 100644 index fb95f5637b..0000000000 --- a/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/ipsec.conf +++ /dev/null @@ -1,34 +0,0 @@ -# /etc/ipsec.conf - strongSwan IPsec configuration file - -config setup - -conn %default - ikelifetime=60m - keylife=20m - rekeymargin=3m - keyingtries=1 - keyexchange=ikev2 - mobike=no - dpdaction=restart - dpddelay=60s - left=%defaultroute - leftfirewall=yes - -conn medsrv - leftid=av9oEPMz@medsrv.org - leftauth=psk - right=PH_IP_CAROL - rightid=carol@strongswan.org - rightauth=pubkey - mediation=yes - auto=start - -conn peer - leftcert=bobCert.pem - leftid=bob@strongswan.org - right=%any - rightid=alice@strongswan.org - rightsubnet=PH_IP_ALICE/32 - mediated_by=medsrv - me_peerid=6cu1UTVw@medsrv.org - auto=add diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/ipsec.secrets b/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/ipsec.secrets deleted file mode 100644 index 0dc3958dae..0000000000 --- a/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/ipsec.secrets +++ /dev/null @@ -1,7 +0,0 @@ -# /etc/ipsec.secrets - strongSwan IPsec secrets file - -: RSA bobKey.pem - -# secret used for mediation connection - -av9oEPMz@medsrv.org : PSK "ZVm3FLOiweS1ywUDpR/L9FvpwNYp9svt" diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/strongswan.conf b/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/strongswan.conf index 93f4345989..7625e5066e 100644 --- a/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/strongswan.conf +++ b/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/strongswan.conf @@ -1,5 +1,5 @@ # /etc/strongswan.conf - strongSwan configuration file charon { - load = random nonce aes sha1 sha2 pem pkcs1 curve25519 gmp x509 curl revocation hmac stroke kernel-netlink socket-default updown + load = random nonce aes sha1 sha2 pem pkcs1 curve25519 gmp x509 curl revocation hmac vici kernel-netlink socket-default updown } diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/swanctl/swanctl.conf b/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/swanctl/swanctl.conf new file mode 100755 index 0000000000..936d40adf9 --- /dev/null +++ b/testing/tests/p2pnat/medsrv-psk/hosts/bob/etc/swanctl/swanctl.conf @@ -0,0 +1,57 @@ +connections { + + medsrv { + remote_addrs = 192.168.0.100 + + local { + auth = psk + id = av9oEPMz@medsrv.org + } + remote { + auth = pubkey + id = carol@strongswan.org + } + children { + medserv { + start_action = start + } + } + version = 2 + mobike = no + mediation = yes + proposals = aes128-sha256-x25519 + } + + peer { + local { + auth = pubkey + certs = bobCert.pem + id = bob@strongswan.org + } + remote { + auth = pubkey + id = alice@strongswan.org + } + children { + peer { + remote_ts = 10.1.0.10 + + updown = /usr/local/libexec/ipsec/_updown iptables + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + mobike = no + mediated_by = medsrv + mediation_peer = 6cu1UTVw@medsrv.org + proposals = aes128-sha256-x25519 + } +} + +secrets { + + ike-medsrv { + id = av9oEPMz@medsrv.org + secret = 0sZVm3FLOiweS1ywUDpR/L9FvpwNYp9svt + } +} diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/ipsec.conf b/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/ipsec.conf deleted file mode 100644 index 4e8a50fb96..0000000000 --- a/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/ipsec.conf +++ /dev/null @@ -1,24 +0,0 @@ -# /etc/ipsec.conf - strongSwan IPsec configuration file - -config setup - -conn %default - ikelifetime=60m - keylife=20m - rekeymargin=3m - keyingtries=1 - keyexchange=ikev2 - mobike=no - dpdaction=clear - dpddelay=60s - -conn medsrv - left=PH_IP_CAROL - leftcert=carolCert.pem - leftid=carol@strongswan.org - leftauth=pubkey - leftfirewall=yes - right=%any - rightauth=psk - mediation=yes - auto=add diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/ipsec.secrets b/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/ipsec.secrets deleted file mode 100644 index 64089431ab..0000000000 --- a/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/ipsec.secrets +++ /dev/null @@ -1,9 +0,0 @@ -# /etc/ipsec.secrets - strongSwan IPsec secrets file - -: RSA carolKey.pem "nH5ZQEWtku0RJEZ6" - -# Mediation clients with random IDs - -6cu1UTVw@medsrv.org : PSK "BAXz/6cSITttd0CzF9799p859Pi4LPnP" - -av9oEPMz@medsrv.org : PSK "ZVm3FLOiweS1ywUDpR/L9FvpwNYp9svt" diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/strongswan.conf b/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/strongswan.conf index af5fa19ef1..58ae9807e8 100644 --- a/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/strongswan.conf +++ b/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/strongswan.conf @@ -1,5 +1,5 @@ # /etc/strongswan.conf - strongSwan configuration file charon { - load = random nonce aes sha1 sha2 md5 pem pkcs1 curve25519 gmp x509 curl revocation hmac stroke kernel-netlink socket-default updown + load = random nonce aes sha1 sha2 md5 pem pkcs1 curve25519 gmp x509 curl revocation hmac vici kernel-netlink socket-default updown } diff --git a/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/swanctl/swanctl.conf b/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/swanctl/swanctl.conf new file mode 100755 index 0000000000..e1b251da5c --- /dev/null +++ b/testing/tests/p2pnat/medsrv-psk/hosts/carol/etc/swanctl/swanctl.conf @@ -0,0 +1,36 @@ +connections { + + medsrv { + local_addrs = 192.168.0.100 + + local { + auth = pubkey + certs = carolCert.pem + id = carol@strongswan.org + } + remote { + auth = psk + } + + version = 2 + mobike = no + mediation = yes + proposals = aes128-sha256-x25519 + } +} + +secrets { + + ike-1 { + id = 6cu1UTVw@medsrv.org + secret = 0sBAXz/6cSITttd0CzF9799p859Pi4LPnP + } + ike-2 { + id = F1ubAio8@medsrv.org + secret = 0s9tb3wiUGqUwCSRIRAwLFWfkdA8u6hHA8 + } + ike-3 { + id = av9oEPMz@medsrv.org + secret = 0sZVm3FLOiweS1ywUDpR/L9FvpwNYp9svt + } +} diff --git a/testing/tests/p2pnat/medsrv-psk/posttest.dat b/testing/tests/p2pnat/medsrv-psk/posttest.dat index 90a7292377..6ce72dc53e 100644 --- a/testing/tests/p2pnat/medsrv-psk/posttest.dat +++ b/testing/tests/p2pnat/medsrv-psk/posttest.dat @@ -1,6 +1,6 @@ -bob::ipsec stop -alice::ipsec stop -carol::ipsec stop +bob::systemctl stop strongswan +alice::systemctl stop strongswan +carol::systemctl stop strongswan alice::iptables-restore < /etc/iptables.flush carol::iptables-restore < /etc/iptables.flush bob::iptables-restore < /etc/iptables.flush diff --git a/testing/tests/p2pnat/medsrv-psk/pretest.dat b/testing/tests/p2pnat/medsrv-psk/pretest.dat index 9505200062..4326723bbc 100644 --- a/testing/tests/p2pnat/medsrv-psk/pretest.dat +++ b/testing/tests/p2pnat/medsrv-psk/pretest.dat @@ -11,9 +11,9 @@ sun::iptables -t nat -A POSTROUTING -o eth0 -s 10.2.0.0/16 -p udp -j SNAT --to-s sun::iptables -t nat -A POSTROUTING -o eth0 -s 10.2.0.0/16 -p tcp -j SNAT --to-source PH_IP_SUN:2000-2100 sun::iptables -A FORWARD -i eth1 -o eth0 -s 10.2.0.0/16 -j ACCEPT sun::iptables -A FORWARD -i eth0 -o eth1 -d 10.2.0.0/16 -j ACCEPT -carol::ipsec start +carol::systemctl start strongswan carol::expect-connection medsrv -bob::ipsec start +bob::systemctl start strongswan bob::sleep 1 -alice::ipsec start +alice::systemctl start strongswan alice::sleep 2 diff --git a/testing/tests/p2pnat/medsrv-psk/test.conf b/testing/tests/p2pnat/medsrv-psk/test.conf index a1c6b8c151..5482c6b8bf 100644 --- a/testing/tests/p2pnat/medsrv-psk/test.conf +++ b/testing/tests/p2pnat/medsrv-psk/test.conf @@ -19,3 +19,7 @@ TCPDUMPHOSTS="moon" # Used for IPsec logging purposes # IPSECHOSTS="alice carol bob" + +# charon controlled by swanctl +# +SWANCTL=1