From: Scott Baker Date: Thu, 23 Jul 2009 18:36:31 +0000 (+0000) Subject: added a function to return the public key string from a keypair object X-Git-Tag: sfa-0.9-0@14641~2 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=75b28610e52976f6ca6df0e62862538406de1eef added a function to return the public key string from a keypair object --- diff --git a/sfa/trust/certificate.py b/sfa/trust/certificate.py index 58486ecf..4a173384 100644 --- a/sfa/trust/certificate.py +++ b/sfa/trust/certificate.py @@ -162,11 +162,21 @@ class Keypair: def as_pem(self): return crypto.dump_privatekey(crypto.FILETYPE_PEM, self.key) + ## + # Return an M2Crypto key object + def get_m2_pkey(self): if not self.m2key: self.m2key = M2Crypto.EVP.load_key_string(self.as_pem()) return self.m2key + ## + # Returns a string containing the public key represented by this object. + + def get_pubkey_string(self): + m2pkey = self.get_m2_pkey() + return base64.b64encode(m2pkey.as_der()) + ## # Return an OpenSSL pkey object