git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e4c3151
)
convert_public_key() should raise an exception instead for returning None
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Wed, 4 Jan 2012 18:16:08 +0000
(13:16 -0500)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Wed, 4 Jan 2012 18:16:08 +0000
(13:16 -0500)
sfa/trust/certificate.py
patch
|
blob
|
history
diff --git
a/sfa/trust/certificate.py
b/sfa/trust/certificate.py
index
f0a2d71
..
595812b
100644
(file)
--- 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:
# we can only convert rsa keys
if "ssh-dss" in key:
- r
eturn None
+ r
aise Exception, "keyconvert: dss keys are not supported"
(ssh_f, ssh_fn) = tempfile.mkstemp()
ssl_fn = tempfile.mktemp()
(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):
# that it can be expected to see why it failed.
# TODO: for production, cleanup the temporary files
if not os.path.exists(ssl_fn):
- r
eturn None
+ r
aise Exception, "keyconvert: generated certificate not found. keyconvert may have failed."
k = Keypair()
try:
k.load_pubkey_from_file(ssl_fn)
k = Keypair()
try:
k.load_pubkey_from_file(ssl_fn)
+ return k
except:
logger.log_exc("convert_public_key caught exception")
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.
##
# Public-private key pairs are implemented by the Keypair class.