summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/keypairs.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/keypairs.py b/nova/api/openstack/compute/contrib/keypairs.py
index 67a081c1a..512f8660a 100644
--- a/nova/api/openstack/compute/contrib/keypairs.py
+++ b/nova/api/openstack/compute/contrib/keypairs.py
@@ -99,7 +99,12 @@ class KeypairController(object):
# import if public_key is sent
if 'public_key' in params:
- fingerprint = crypto.generate_fingerprint(params['public_key'])
+ try:
+ fingerprint = crypto.generate_fingerprint(params['public_key'])
+ except exception.InvalidKeypair:
+ msg = _("Keypair data is invalid")
+ raise webob.exc.HTTPBadRequest(explanation=msg)
+
keypair['public_key'] = params['public_key']
keypair['fingerprint'] = fingerprint
else: