From bb64603b41b51eb429304059d8457568b2588ee5 Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Thu, 25 Jul 2024 17:27:36 +0300 Subject: op_mode: T5744: PKI import OpenVPN shared key includess unexpected BEGIN and END --- src/op_mode/pki.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/op_mode/pki.py b/src/op_mode/pki.py index 9ce166c7d..84b080023 100755 --- a/src/op_mode/pki.py +++ b/src/op_mode/pki.py @@ -844,7 +844,8 @@ def import_openvpn_secret(name, path): key_version = '1' with open(path) as f: - key_lines = f.read().split("\n") + key_lines = f.read().strip().split("\n") + key_lines = list(filter(lambda line: not line.strip().startswith('#'), key_lines)) # Remove commented lines key_data = "".join(key_lines[1:-1]) # Remove wrapper tags and line endings version_search = re.search(r'BEGIN OpenVPN Static key V(\d+)', key_lines[0]) # Future-proofing (hopefully) -- cgit v1.2.3