From b7d88cadf2469efa09d0e760379626d6c5ae6284 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Wed, 4 Jan 2012 13:16:08 -0500 Subject: [PATCH 1/1] convert_public_key() should raise an exception instead for returning None --- sfa/trust/certificate.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sfa/trust/certificate.py b/sfa/trust/certificate.py index f0a2d71c..595812b5 100644 --- a/sfa/trust/certificate.py +++ b/sfa/trust/certificate.py @@ -89,7 +89,7 @@ def convert_public_key(key): # we can only convert rsa keys if "ssh-dss" in key: - return None + raise Exception, "keyconvert: dss keys are not supported" (ssh_f, ssh_fn) = tempfile.mkstemp() ssl_fn = tempfile.mktemp() @@ -103,20 +103,22 @@ def convert_public_key(key): # that it can be expected to see why it failed. # TODO: for production, cleanup the temporary files if not os.path.exists(ssl_fn): - return None + raise Exception, "keyconvert: generated certificate not found. keyconvert may have failed." k = Keypair() try: k.load_pubkey_from_file(ssl_fn) + return k except: logger.log_exc("convert_public_key caught exception") - k = None + raise + finally: + # remove the temporary files + if os.path.exists(ssh_fn): + os.remove(ssh_fn) + if os.path.exists(ssl_fn): + os.remove(ssl_fn) - # remove the temporary files - os.remove(ssh_fn) - os.remove(ssl_fn) - - return k ## # Public-private key pairs are implemented by the Keypair class. -- 2.43.0