summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2026-03-04 12:01:50 +0200
committerGitHub <noreply@github.com>2026-03-04 12:01:50 +0200
commit2a4d52b2b8c39f4f77b526ce80686247dd4d0f95 (patch)
treeedcf61a295a71c50d8ca20c22a8bec3378f5e86d /src/conf_mode
parent3030e33b26c1a895179747f2444a0cd79d59f891 (diff)
parent673ec335b885ae1de8391dd8c48a5fe16b282db5 (diff)
downloadvyos-1x-2a4d52b2b8c39f4f77b526ce80686247dd4d0f95.tar.gz
vyos-1x-2a4d52b2b8c39f4f77b526ce80686247dd4d0f95.zip
Merge pull request #4930 from giga1699/T8136
ipsec: T8136: IPSEC PPK support
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/vpn_ipsec.py59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/conf_mode/vpn_ipsec.py b/src/conf_mode/vpn_ipsec.py
index c6492f513..3b5918218 100755
--- a/src/conf_mode/vpn_ipsec.py
+++ b/src/conf_mode/vpn_ipsec.py
@@ -54,6 +54,7 @@ from vyos.utils.vti_updown_db import vti_updown_db_exists
from vyos.utils.vti_updown_db import open_vti_updown_db_for_create_or_update
from vyos.utils.vti_updown_db import remove_vti_updown_db
from vyos import ConfigError
+from vyos.base import Warning
from vyos import airbag
airbag.enable()
@@ -261,11 +262,29 @@ def verify(ipsec):
if not ipsec or 'deleted' in ipsec:
return
+ # T8136 PPK support; keep a list of PPK IDs
+ ppk_ids = []
+
if 'authentication' in ipsec:
if 'psk' in ipsec['authentication']:
for psk, psk_config in ipsec['authentication']['psk'].items():
if 'id' not in psk_config or 'secret' not in psk_config:
- raise ConfigError(f'Authentication psk "{psk}" missing "id" or "secret"')
+ raise ConfigError(
+ f'Authentication psk "{psk}" missing "id" or "secret"'
+ )
+ # T8136 PPK Support; Check that PPK has an ID and secret defined, and ID is unique
+ if 'ppk' in ipsec['authentication']:
+ for ppk, ppk_config in ipsec['authentication']['ppk'].items():
+ if 'id' not in ppk_config:
+ raise ConfigError(f'Authentication PPK "{ppk}" missing "id"')
+ if 'secret' not in ppk_config:
+ raise ConfigError(f'Authentication PPK "{ppk}" missing "secret"')
+ for ppk_id in ppk_config['id']:
+ if ppk_id in ppk_ids:
+ raise ConfigError(
+ f'Authentication PPK "{ppk}" has duplicate ID "{ppk_id}" from another PPK. IDs should be unique.'
+ )
+ ppk_ids.append(ppk_id)
if 'interface' in ipsec:
tmp = re.compile(dynamic_interface_pattern)
@@ -445,6 +464,25 @@ def verify(ipsec):
elif 'pool' not in ipsec['remote_access'] or pool not in ipsec['remote_access']['pool']:
raise ConfigError(f'Requested pool "{pool}" does not exist!')
+ # T8136 IPSEC PPK Support
+ # PPKs and Childless only works with IKEv2. Check that ike-group is v2 if either option is enabled. Check that PPK ID was actually defined in authentication. Recommend use of childless when using PPKs if not already configured.
+ if 'ppk' in ra_conf['authentication']:
+ ike = ra_conf['ike_group']
+ if dict_search(f'ike_group.{ike}.key_exchange', ipsec) != 'ikev2':
+ raise ConfigError(
+ f'Incorrect configuration in IKE group "{ike}": post-quantum pre-shared keys require explicit IKEv2 usage.'
+ )
+ if 'childless' not in ra_conf:
+ Warning(
+ 'It is recommended to use childless IKE SAs when using PPKs'
+ )
+ if 'childless' in ra_conf:
+ ike = ra_conf['ike_group']
+ if dict_search(f'ike_group.{ike}.key_exchange', ipsec) != 'ikev2':
+ raise ConfigError(
+ f'Incorrect configuration in IKE group "{ike}": childless IKE SAs can only be used with IKEv2.'
+ )
+
if 'pool' in ipsec['remote_access']:
pool_networks = []
for pool, pool_config in ipsec['remote_access']['pool'].items():
@@ -653,6 +691,25 @@ def verify(ipsec):
f'for ESP proposal {proposal} on tunnel {tunnel} for site-to-site peer {peer} with VPP'
)
+ # T8136 IPSEC PPK Support
+ # PPKs and Childless only works with IKEv2. Check that ike-group is v2 if either option is enabled. Check that PPK ID was actually defined in authentication. Recommend use of childless when using PPKs if not already configured.
+ if 'ppk' in peer_conf['authentication']:
+ ike = peer_conf['ike_group']
+ if dict_search(f'ike_group.{ike}.key_exchange', ipsec) != 'ikev2':
+ raise ConfigError(
+ f'Post-quantum preshared keys must be used with IKEv2! Please configure IKEv2 key-exchange in ike-group "{ike}".'
+ )
+ if 'childless' not in peer_conf:
+ Warning(
+ 'It is recommended to use childless IKE SAs when using PPKs'
+ )
+ if 'childless' in peer_conf:
+ ike = peer_conf['ike_group']
+ if dict_search(f'ike_group.{ike}.key_exchange', ipsec) != 'ikev2':
+ raise ConfigError(
+ f'Childless IKE SAs be used with IKEv2! Please configure IKEv2 key-exchange in ike-group "{ike}".'
+ )
+
def cleanup_pki_files():
for path in [CERT_PATH, CA_PATH, CRL_PATH, KEY_PATH, PUBKEY_PATH]: