X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Ftrust%2Fcertificate.py;h=d0d36d536ed235b87ff9236f11c5c8a1cc5da403;hb=04acd3228e5911d36d0cd58dc35b9319fc558e17;hp=e05d3a1c30e1019b5aaf0e9cd9b41e87254c3784;hpb=847e5b53e0030190f9d16ccfa52597eeb9a260ef;p=sfa.git diff --git a/sfa/trust/certificate.py b/sfa/trust/certificate.py index e05d3a1c..d0d36d53 100644 --- a/sfa/trust/certificate.py +++ b/sfa/trust/certificate.py @@ -57,8 +57,6 @@ import OpenSSL # M2Crypto is imported on the fly to minimize crashes # import M2Crypto -from sfa.util.py23 import PY3 - from sfa.util.faults import (CertExpired, CertMissingParent, CertNotSignedByParent) from sfa.util.sfalogging import logger @@ -117,7 +115,7 @@ def convert_public_key(key): (ssh_f, ssh_fn) = tempfile.mkstemp() ssl_fn = tempfile.mktemp() - os.write(ssh_f, key) + os.write(ssh_f, key.encode()) os.close(ssh_f) cmd = keyconvert_path + " " + ssh_fn + " " + ssl_fn @@ -276,8 +274,7 @@ class Keypair: def get_m2_pubkey(self): import M2Crypto if not self.m2key: - self.m2key = M2Crypto.EVP.load_key_string( - self.as_pem().encode(encoding="utf-8")) + self.m2key = M2Crypto.EVP.load_key_string(self.as_pem()) return self.m2key ## @@ -475,7 +472,7 @@ class Certificate: return "" string = OpenSSL.crypto.dump_certificate( OpenSSL.crypto.FILETYPE_PEM, self.x509) - if PY3 and isinstance(string, bytes): + if isinstance(string, bytes): string = string.decode() if save_parents and self.parent: string = string + self.parent.save_to_string(save_parents) @@ -492,7 +489,7 @@ class Certificate: f = filep else: f = open(filename, 'w') - if PY3 and isinstance(string, bytes): + if isinstance(string, bytes): string = string.decode() f.write(string) f.close()