summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2016-03-20 18:44:23 +0100
committerRuben Pollan <meskio@sindominio.net>2016-03-20 20:01:01 +0100
commit06e6825e37a6f5fa2df2620e7dfa1687b7029ff6 (patch)
tree60e5ca4013d1b91fd77cd74c4a06b5cd0a034f4c
parent628da289584c8c7b218016ea8aa0740aaa36acb6 (diff)
[bug] Return KeyNotFound Failure if not valid key is given to put_raw_key
- Resolves: #7974
-rw-r--r--keymanager/changes/next-changelog.txt2
-rw-r--r--keymanager/src/leap/keymanager/__init__.py11
2 files changed, 10 insertions, 3 deletions
diff --git a/keymanager/changes/next-changelog.txt b/keymanager/changes/next-changelog.txt
index 163c1eeb..2dd34d4a 100644
--- a/keymanager/changes/next-changelog.txt
+++ b/keymanager/changes/next-changelog.txt
@@ -21,6 +21,8 @@ Features
Bugfixes
~~~~~~~~
+- `#7974 <https://leap.se/code/issues/7974>`_: Return KeyNotFound Failure if not valid key is given to put_raw_key.
+
- `#1235 <https://leap.se/code/issues/1235>`_: Description for the fixed stuff corresponding with issue #1235.
- Bugfix without related issue number.
diff --git a/keymanager/src/leap/keymanager/__init__.py b/keymanager/src/leap/keymanager/__init__.py
index 9e3b6ee2..1106c235 100644
--- a/keymanager/src/leap/keymanager/__init__.py
+++ b/keymanager/src/leap/keymanager/__init__.py
@@ -820,9 +820,10 @@ class KeyManager(object):
:return: A Deferred which fires when the key is in the storage, or
which fails with KeyAddressMismatch if address doesn't match
- any uid on the key or fails with KeyNotValidUpdate if a key
- with the same uid exists and the new one is not a valid update
- for it.
+ any uid on the key or fails with KeyNotFound if no OpenPGP
+ material was found in key or fails with KeyNotValidUpdate if a
+ key with the same uid exists and the new one is not a valid
+ update for it.
:rtype: Deferred
:raise UnsupportedKeyTypeError: if invalid key type
@@ -831,6 +832,10 @@ class KeyManager(object):
_keys = self._wrapper_map[ktype]
pubkey, privkey = _keys.parse_ascii_key(key, address)
+
+ if pubkey is None:
+ return defer.fail(KeyNotFound(key))
+
pubkey.validation = validation
d = self.put_key(pubkey)
if privkey is not None: