@@ -168,6 +168,14 @@ def verify_pki(openvpn):
168
168
'verification, consult the documentation for details.' )
169
169
170
170
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
+
171
179
if (mode in ['server' , 'client' ]) and ('ca_certificate' not in tls ):
172
180
raise ConfigError (f'Must specify "tls ca-certificate" on openvpn interface { interface } ,\
173
181
it is required in server and client modes' )
@@ -260,11 +268,6 @@ def verify(openvpn):
260
268
# OpenVPN site-to-site - VERIFY
261
269
#
262
270
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
-
268
271
if 'local_address' not in openvpn and 'is_bridge_member' not in openvpn :
269
272
raise ConfigError ('Must specify "local-address" or add interface to bridge' )
270
273
0 commit comments