summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2024-07-25 17:27:36 +0300
committerNataliia Solomko <natalirs1985@gmail.com>2024-07-25 17:27:36 +0300
commitbb64603b41b51eb429304059d8457568b2588ee5 (patch)
tree4d731a1a47a5acdb54d04eab66de885bd676b9aa /src
parent42a3be5b079f005115ce107935929ebb4a7139e0 (diff)
downloadvyos-1x-bb64603b41b51eb429304059d8457568b2588ee5.tar.gz
vyos-1x-bb64603b41b51eb429304059d8457568b2588ee5.zip
op_mode: T5744: PKI import OpenVPN shared key includess unexpected BEGIN and END
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/pki.py3
1 files changed, 2 insertions, 1 deletions
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)