X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=sfa%2Ftrust%2Fcertificate.py;h=b34e5cdef133c2575b4b6a4acb1e3b59d70b5bf1;hb=45338f7871090811a83ee4eb1f4d9c5de588200c;hp=4a173384ba4d52a20fe172c3b3e6dc1af219ce27;hpb=75b28610e52976f6ca6df0e62862538406de1eef;p=sfa.git diff --git a/sfa/trust/certificate.py b/sfa/trust/certificate.py index 4a173384..b34e5cde 100644 --- a/sfa/trust/certificate.py +++ b/sfa/trust/certificate.py @@ -18,6 +18,7 @@ import os import tempfile import base64 +import traceback from OpenSSL import crypto import M2Crypto from M2Crypto import X509 @@ -32,7 +33,6 @@ def convert_public_key(key): # we can only convert rsa keys if "ssh-dss" in key: - print "XXX: DSA key encountered, ignoring" return None (ssh_f, ssh_fn) = tempfile.mkstemp() @@ -42,19 +42,18 @@ def convert_public_key(key): cmd = keyconvert_path + " " + ssh_fn + " " + ssl_fn os.system(cmd) - + # this check leaves the temporary file containing the public key so # that it can be expected to see why it failed. # TODO: for production, cleanup the temporary files if not os.path.exists(ssl_fn): - report.trace(" failed to convert key from " + ssh_fn + " to " + ssl_fn) return None - + k = Keypair() try: k.load_pubkey_from_file(ssl_fn) except: - print "XXX: Error while converting key: ", key_str + traceback.print_exc() k = None # remove the temporary files @@ -201,6 +200,9 @@ class Keypair: k.verify_update(data) return M2Crypto.m2.verify_final(k.ctx, base64.b64decode(sig), k.pkey) + def compute_hash(self, value): + return self.sign_string(str(value)) + ## # The certificate class implements a general purpose X509 certificate, making # use of the appropriate pyOpenSSL or M2Crypto abstractions. It also adds @@ -514,10 +516,14 @@ class Certificate: # until a certificate is found that is signed by a trusted root. # TODO: verify expiration time - + #print "====Verify Chain=====" # if this cert is signed by a trusted_cert, then we are set for trusted_cert in trusted_certs: + #print "***************" # TODO: verify expiration of trusted_cert ? + #print "CLIENT CERT", self.dump() + #print "TRUSTED CERT", trusted_cert.dump() + #print "Client is signed by Trusted?", self.is_signed_by_cert(trusted_cert) if self.is_signed_by_cert(trusted_cert): #print self.get_subject(), "is signed by a root" return