Skip to content

Commit 3bfd917

Browse files
dmbaturinmergify[bot]
authored andcommitted
openvpn: T6374: only check TLS role for s2s if TLS is configured
(cherry picked from commit f406958)
1 parent 48a5ae3 commit 3bfd917

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/conf_mode/interfaces_openvpn.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ def verify_pki(openvpn):
168168
'verification, consult the documentation for details.')
169169

170170
if tls:
171+
if mode == 'site-to-site':
172+
# XXX: site-to-site with PSKs is the only mode that can work without TLS,
173+
# so 'tls role' is not mandatory for it,
174+
# but we need to check that if it uses peer certificate fingerprints rather than PSKs,
175+
# then the TLS role is set
176+
if ('shared_secret_key' not in tls) and ('role' not in tls):
177+
raise ConfigError('"tls role" is required for site-to-site OpenVPN with TLS')
178+
171179
if (mode in ['server', 'client']) and ('ca_certificate' not in tls):
172180
raise ConfigError(f'Must specify "tls ca-certificate" on openvpn interface {interface},\
173181
it is required in server and client modes')
@@ -260,11 +268,6 @@ def verify(openvpn):
260268
# OpenVPN site-to-site - VERIFY
261269
#
262270
elif openvpn['mode'] == 'site-to-site':
263-
# XXX: site-to-site is the only mode that still can work without TLS,
264-
# so we need to make sure that if TLS is used, then TLS role is also specified
265-
if 'shared_secret_key' not in openvpn['tls'] and 'role' not in openvpn['tls']:
266-
raise ConfigError('"tls role" is required for site-to-site OpenVPN with TLS')
267-
268271
if 'local_address' not in openvpn and 'is_bridge_member' not in openvpn:
269272
raise ConfigError('Must specify "local-address" or add interface to bridge')
270273

0 commit comments

Comments
 (0)