Skip to content

Commit d2077a6

Browse files
committed
[fix] Convert parameter tls_cipher to a list #349
Fixes #349 Signed-off-by: Oliver Kraitschy <[email protected]>
1 parent 777ddfb commit d2077a6

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

netjsonconfig/backends/openwrt/converters/openvpn.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def __intermediate_vpn(self, vpn):
1515
"enabled": not vpn.pop("disabled", False),
1616
}
1717
)
18+
if (cipher := vpn.get("tls_cipher")) and isinstance(cipher, str):
19+
vpn["tls_cipher"] = [cipher]
1820
return super().__intermediate_vpn(vpn, remove=[""])
1921

2022
def __netjson_vpn(self, vpn):
@@ -24,4 +26,6 @@ def __netjson_vpn(self, vpn):
2426
vpn["disabled"] = vpn.pop("enabled", "0") == "0"
2527
vpn["name"] = vpn.pop(".name")
2628
del vpn[".type"]
29+
if (cipher := vpn.get("tls_cipher")) and isinstance(cipher, list) and cipher:
30+
vpn["tls_cipher"] = cipher[0]
2731
return super().__netjson_vpn(vpn)

tests/openvpn/test_backend.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def test_client_mode(self):
257257
"status_version": 1,
258258
"tls_client": True,
259259
"tls_auth": "tls_auth.key 1",
260+
"tls_cipher": "TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0",
260261
"topology": "p2p",
261262
"tun_ipv6": True,
262263
"up": "/home/user/up-command.sh",
@@ -302,6 +303,7 @@ def test_client_mode(self):
302303
status /var/log/openvpn.status 30
303304
status-version 1
304305
tls-auth tls_auth.key 1
306+
tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0
305307
tls-client
306308
topology p2p
307309
tun-ipv6

tests/openvpn/test_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def test_parse_server(self):
7474
script-security 0
7575
status /var/log/openvpn.status 10
7676
status-version 1
77+
tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0
7778
tls-server
7879
user nobody
7980
verb 3
@@ -110,6 +111,7 @@ def test_parse_server(self):
110111
"script_security": 0,
111112
"status": "/var/log/openvpn.status 10",
112113
"status_version": 1,
114+
"tls_cipher": "TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0",
113115
"tls_server": True,
114116
"user": "nobody",
115117
"verb": 3,

tests/openwrt/test_openvpn.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def test_parse_server_mode_data_ciphers(self):
211211
"script_security": 1,
212212
"status": "/var/log/openvpn.status 30",
213213
"status_version": 1,
214+
"tls_cipher": "TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0",
214215
"tls_client": True,
215216
"tun_ipv6": True,
216217
"up": "/home/user/up-command.sh",
@@ -254,6 +255,7 @@ def test_parse_server_mode_data_ciphers(self):
254255
option script_security '1'
255256
option status '/var/log/openvpn.status 30'
256257
option status_version '1'
258+
list tls_cipher 'TLS-DHE-RSA-WITH-AES-256-CBC-SHA:@SECLEVEL=0'
257259
option tls_client '1'
258260
option tun_ipv6 '1'
259261
option up '/home/user/up-command.sh'

0 commit comments

Comments
 (0)