diff options
author | Christian Breunig <christian@breunig.cc> | 2024-08-20 07:18:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-20 07:18:17 +0200 |
commit | 538930c27a0984cd9f9a58115e6ea6395002707e (patch) | |
tree | ba08df6788d04c1736437c7666d0aa601999a9e5 /python | |
parent | 26ebd3af8cd2aa296621dbda11ac1c1e64514ba9 (diff) | |
parent | 27fb633bbe45321eecd8225c32a2fd16882633a9 (diff) | |
download | vyos-1x-538930c27a0984cd9f9a58115e6ea6395002707e.tar.gz vyos-1x-538930c27a0984cd9f9a58115e6ea6395002707e.zip |
Merge pull request #3977 from natali-rs1985/T5743-current
T5743: HTTPS API ability to import PKI certificates
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configsession.py | 11 | ||||
-rw-r--r-- | python/vyos/pki.py | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/python/vyos/configsession.py b/python/vyos/configsession.py index ccf2ce8f2..7d51b94e4 100644 --- a/python/vyos/configsession.py +++ b/python/vyos/configsession.py @@ -34,6 +34,9 @@ MIGRATE_LOAD_CONFIG = ['/usr/libexec/vyos/vyos-load-config.py'] SAVE_CONFIG = ['/usr/libexec/vyos/vyos-save-config.py'] INSTALL_IMAGE = ['/usr/libexec/vyos/op_mode/image_installer.py', '--action', 'add', '--no-prompt', '--image-path'] +IMPORT_PKI = ['/opt/vyatta/bin/vyatta-op-cmd-wrapper', 'import'] +IMPORT_PKI_NO_PROMPT = ['/usr/libexec/vyos/op_mode/pki.py', + '--action', 'import', '--no-prompt'] REMOVE_IMAGE = ['/usr/libexec/vyos/op_mode/image_manager.py', '--action', 'delete', '--no-prompt', '--image-name'] SET_DEFAULT_IMAGE = ['/usr/libexec/vyos/op_mode/image_manager.py', @@ -239,6 +242,14 @@ class ConfigSession(object): out = self.__run_command(REMOVE_IMAGE + [name]) return out + def import_pki(self, path): + out = self.__run_command(IMPORT_PKI + path) + return out + + def import_pki_no_prompt(self, path): + out = self.__run_command(IMPORT_PKI_NO_PROMPT + path) + return out + def set_default_image(self, name): out = self.__run_command(SET_DEFAULT_IMAGE + [name]) return out diff --git a/python/vyos/pki.py b/python/vyos/pki.py index 27fe793a8..5a0e2ddda 100644 --- a/python/vyos/pki.py +++ b/python/vyos/pki.py @@ -271,7 +271,7 @@ def load_private_key(raw_data, passphrase=None, wrap_tags=True): try: return serialization.load_pem_private_key(bytes(raw_data, 'utf-8'), password=passphrase) - except ValueError: + except (ValueError, TypeError): return False def load_openssh_public_key(raw_data, type): |